Calculate vector for projectile to reach another block

Discussion in 'Plugin Development' started by Guccify, Dec 18, 2014.

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

    Guccify

    Say I have an Entity spawned at a player's location. How would I calculate the vector needed for the Entity to reach a block, for example, 100 blocks away from the player?

    I've tried vector subtraction:
    Code:
    Vector vector = end_loc.toVector().subtract(player.getLocation().toVector());
    But the entity falls straight down.
     
  2. Offline

    Webbeh

    Do you want the "vector that should reach that entity" to be something doing the same curve as an arrow ? Because if so, you need to compute the initial vector, and that's basic ballistic. It only requires you to know bukkit's gravity force (and friction force, if any), to have the correct angle.

    Otherwise, if you want a vector that goes on a straight line, it's far easier.
     
  3. Offline

    ChipDev

    Have you looked at my post in resources?
     
Thread Status:
Not open for further replies.

Share This Page