Direction from player1 to player2 (Vector)

Discussion in 'Plugin Development' started by ewrs, Apr 28, 2019.

Thread Status:
Not open for further replies.
  1. Offline

    ewrs

    Hey. I had some difficulties with the direction. I want to use a team to get directions from one player to another. That is, the vector, but I can not get 2 days.

    thank


    P.S.
    стрелочки.JPG
    These arrows from the figure I need to bring the player, but I do not really understand how I need to get them.
     
  2. Offline

    MightyOne

    @ewrs Dou you want the vectors to always depict a certain shape like a square or something? Or are you just interested in the distance of player 4 to 3, of player 3 to 2, etc.?

    For the latter one you will just need 3 methods:
    Player#getLocation(),
    Location#subtract(Location) and
    Location#toVector()
     
  3. Offline

    ewrs

    I want an arrow to tell the player where player 2 is
     
  4. Offline

    MightyOne

    vecmath.png

    Vector a equals player1.getLocation().toVector().
    Vector b equals player2.getLocation().toVector().

    If you subtract vector a from vector b you receive the vector from one player to the other player.
    The length of this new vector is also the distance between the players.

    Does this make sense for you?
     
    Dai_Kunai likes this.
Thread Status:
Not open for further replies.

Share This Page