Solved [Help] An arrow leading to player

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

xDolarlar

Member
Apr 25, 2023
2
0
1
18
Hi, Im trying to make that when /point <player> command is executed there will be an send title action to tell player how to reach the arg-1 player the fastest example Right, Left, Down, Up, Forward, Backward

I'm very confused about this and my math is not enough :emoji_grinning:

Here is what i have right now (Does not even load crashes when loading):

Code:
import:
    java.lang.Math

command /point [<player>]:
    trigger:
        if arg-1 is not set:
            send "&cUsage: /point <player>" to player
        else:
            set {_x} to (((Math).sin({_yaw}) * -1) * (z component of (location of arg-1) - z component of (location of player)) + ((Math).cos({_yaw}) * -1) * (component of (location of arg-1) - x component of (location of player)))
            set {_z} to (((Math).cos({_yaw}) * -1) * (z component of (location of arg-1) - z component of (location of player))) - (((Math).sin({_yaw}) * -1) * (x component of (location of arg-1) - x component of (location of player)))
            if {_z} > 0:
                send title "&aMove forwards to reach &f%arg-1%&a fastest" to player for 10 ticks
            else if {_z} < 0:
                send title "&aMove backwards to reach &f%arg-1%&a fastest" to player for 10 ticks
            else:
                if {_x} > 0:
                    send title "&aMove to the right to reach &f%arg-1%&a fastest" to player for 10 ticks
                else if {_x} < 0:
                    send title "&aMove to the left to reach &f%arg-1%&a fastest" to player for 10 ticks
                else:
                    send title "&aYou are already at &f%arg-1%'s&a location" to player for 10 ticks
[doublepost=1682424812,1682404530][/doublepost]Ok fixed it here is the code:

Code:
function waytogo(p: player, goal: location) :: text:
    set {_vec} to vector from {_p} to {_goal}
    set {_yaw} to yaw of {_vec}
    subtract (yaw of {_p}) from {_yaw}
    while {_yaw} is less than -180:
        add 360 to {_yaw}
    while {_yaw} is more than 180:
        subtract 360 from {_yaw}
    set {_last2} to "→"
    if {_yaw} is less than 0:
        set {_last2} to "←"
    if (abs({_yaw})) < 6:
        set {_last2} to "↑"
    return {_last2}

This will return the arrow emoji of which location is the fastest way to go to the goal

Thanks to
{members::2002Spiele}
for helping at skUnity discord!