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

    ¡Hola! Title says it all!

    Thanks in advance ;D!
     
  2. Offline

    izak12345678910

    What do you mean
     
    SiLeNT_F1NISH likes this.
  3. Offline

    Hoolean

    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

    Moved to Plugin Development.
     
  5. Offline

    Hoolean

    THANK YOU!!!
     
  6. Offline

    andf54

    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

    Courier

    You should just teleport the entity, but if you really want to know how to set their velocity:
    Code:java
    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

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

    Courier

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

    Hoolean

    Oh yeah!

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

Share This Page