How to set a players velocity so that he shoots at another player?

Discussion in 'Plugin Development' started by AstramG, Aug 25, 2013.

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

    AstramG

    How can I make a player's velocity in a way that it shoots at the selected player? I want it to basically be able to have a player shoot themselves right at another player with velocity. If you can do this, can you please make it shoot them a little further than the player so it looks like they went through the player and not just inside the target player. Thank you!
     
  2. Offline

    NoLiver92

    is this a asking for help post or a plugin request?

    heres a good post which will teach you how to do it: this
     
  3. Offline

    AstramG

    Well this is more of a help post because I'm asking for assistance with implementing this in my plugin.
    I've tried calculating vectors myself but I'm not too good at it.
     
  4. Offline

    chasechocolate

    AstramG try something like this:
    Code:java
    1. Location from = player.getLocation();
    2. Location to = playerToLaunchTo.getLocation();
    3. Vector velocity = to.toVector().subtract(from.toVector()).normalize();
    4.  
    5. //Use velocity.multiply(speed) to change how fast they go

    Not entirely sure if it will work, though.
     
  5. Offline

    AstramG

Thread Status:
Not open for further replies.

Share This Page