Player launching deviation

Discussion in 'Plugin Development' started by TheSporech, May 1, 2016.

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

    TheSporech

    Hi, I have a bit of code which launches players in the direction they're looking at, and it works, except on occasion, players will drift left or right and I don't know how to stop it from happening.
    Code:
    Vector v = new Vector(player.getEyeLocation().getDirection().getX(),0.01,player.getEyeLocation().getDirection().getZ());
    System.out.println(v);
    player.setVelocity(v.multiply(10));
    Does anyone know of a solution?
     
  2. Offline

    Lolmewn

    What do you mean by "drift" left or right?
     
  3. To launch players where they are looking, simply do this:
    Code:
    player.setVelocity(player.getDirection().normalize().multiply(10));
    
    EDIT: Of course if you don't want them going up, just do the same thing.
    Code:
    player.getDirection().getX()...
     
Thread Status:
Not open for further replies.

Share This Page