Solved Using velocitys to move an entity to a location

Discussion in 'Plugin Development' started by Hoolean, Nov 2, 2012.

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

    Hoolean Retired Staff

    ¡Hola! Title says it all!

    Thanks in advance ;D!
  2. Offline


    What do you mean
    SiLeNT_F1NISH likes this.
  3. Offline

    Hoolean Retired Staff

    A way to set their velocity to which will make an entity travel to a destination. A formula.

    Arrgghhh! Wrong forum! Meant Plugin Development :(

    Oh geez that's embarrising :'(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 29, 2016
  4. Offline

    TnT Retired Staff

    Moved to Plugin Development.
  5. Offline

    Hoolean Retired Staff

    THANK YOU!!!
  6. Offline


    Vector velocity = location.getLocation().subtract(player.getLocation()).toVector().normalize().multiply(speed);
    Assign this velocity to the player. Use scheduler to set velocity again when player looses speed.
  7. Offline


    You should just teleport the entity, but if you really want to know how to set their velocity:
    1. void moveNextTick(Entity ent, Location loc)
    2. {
    3. ent.setVelocity(loc.subtract(ent.getLocation()).toVector());
    4. }
    This should move the entity there in the next tick (assuming it doesn't hit any walls), but it will keep going too, unless you reset its velocity.
  8. Offline

    Hoolean Retired Staff

    So you could multiply that by a value to slow/speed it up?
  9. Offline


    Yeah. If you want to have a certain speed, do what andf54 said.
  10. Offline

    Hoolean Retired Staff

    Oh yeah!

    Thanks everyone!
Thread Status:
Not open for further replies.

Share This Page