Forcing the player to move?

Discussion in 'Plugin Development' started by DarkBladee12, Jan 27, 2013.

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

    DarkBladee12

    Is it possible to force a real player to move to a specific location? I tried with calling the PlayerMoveEvent, but that won't work :/
     
  2. Offline

    ZeusAllMighty11

    You can't make the player walk there, but you can teleport them AFAIK
     
  3. Offline

    DarkBladee12

    ZeusAllMighty11 Hmm but it should be possible to force entities to move to a specific location?
     
  4. Offline

    ZeusAllMighty11

    Hmmm yes entities. I guess a player is an entity, but it has no paths goals thing
     
  5. Offline

    curlyfries1999

    I'm pretty sure you can change the player's velocity but I've never got it to work
     
  6. Offline

    fireblast709

    Player#setVelocity(Vector) forces the player to 'fly' towards that direction (unless there is a Block in the way)
     
  7. Offline

    DarkBladee12

    fireblast709 how would I get the correct velocity, so that the player will move to the specific location?

    ZeusAllMighty11 how can I make a mob move with/without making a modified entity class?

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

    DarkBladee12

    Anyone knows a solution?
     
  9. Offline

    Cjreek

  10. Offline

    DarkBladee12

    That would help me with my mob problem, but not with the player problem... How would I get the velocity for moving the player to a specific location?
     
  11. Offline

    AbsolutePotato

    Get the distance, and graph a parabola/vector, set player to that vector. Requires some math knowledge.
     
  12. Offline

    DarkBladee12

    AbsolutePotato could you help me with this? I'm not very good at maths :p
     
  13. Offline

    AbsolutePotato

    DarkBladee12
    Probably something like this :
    Code:
    Location location = [any location you want here]
    Int speed = [any number]
    Vector dir = location.toVector().subtract(player.getLocation().toVector()).normalize();
    player.setVelocity(dir.multiply(speed));
    
    Where speed is any number.
    Didn't require as much math as I thought.
     
  14. Offline

    DarkBladee12

Thread Status:
Not open for further replies.

Share This Page