Getting and setting the pitch of a vector?

Discussion in 'Plugin Development' started by r0llingthund3r, Aug 1, 2014.

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

    r0llingthund3r

    I have these 2 vectors.
    Code:java
    1. p.setVelocity(new Vector(p.getLocation().getDirection().getX(), 1.5, p.getLocation().getDirection().getZ()));
    2. p.setVelocity(p.getEyeLocation().getDirection().multiply(5));

    The first vector propels the player into the air, while the second vector is supposed to send them slamming into the ground. However, the second vector could potentially serve as a second jump. To prevent this, I would like to check if the player's pitch if less than 40, and if it is, set it to 40. Unfortunately I have no idea how to set the pitch of a vector...
     
  2. Offline

    r0llingthund3r

    DJSkepter That is an excellent idea. Thank you very much for the help and apologies for the late reply.
     
  3. Offline

    fireblast709

    r0llingthund3r can't you just get the Player's pitch from the Location object?
     
    DJSkepter likes this.
  4. Offline

    r0llingthund3r

    fireblast709 The title is poorly worded. I knew how to get the pitch I just didn't know how to apply it to my vector.
     
  5. Offline

    fireblast709

    r0llingthund3r since you have a Location object, use setPitch followed by getDirection(), and let Bukkit do the math
     
Thread Status:
Not open for further replies.

Share This Page