Solved Launch A Player Towards Another Location

Discussion in 'Plugin Development' started by Evonoucono, Aug 7, 2015.

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

    Evonoucono

    The title says it all. This is what I am trying to work with:
    Code:
    player.setVelocity(player.getLocation().getDirection().multiply(8).setY(1.3));
    However I think the getDirection() part needs to be changed to something that will get the direction of the player to another location. But I can't figure out what to put, or if this code here is completely worthless to what I am trying to do. Any suggestions?

    Bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 11, 2016
  2. Offline

    Lammazz

    @Evonoucono
    getDirection() will return a vector which is the direction the player is currently looking. It sounds like what you want is to shoot them towards any location you choose, if that is so you will need to learn some 3d vector maths to get the vector pointing from one location to another then applying that to the player's velocity. Google will be your best friend in this case.

    EDIT: After a few minutes of searching I found a really good tutorial on bukkit about this subject. https://bukkit.org/threads/tutorial-how-to-calculate-vectors.138849/
     
    Last edited: Aug 7, 2015
  3. otherVector.subtract(vector)
     
  4. Offline

    Evonoucono

    Got It working, Thanks!
     
    Last edited: Aug 8, 2015
  5. Just so you know, you may only bump every 24 hours, not every hour. And if it's solved please mark the thread as solved.
     
Thread Status:
Not open for further replies.

Share This Page