[SOLVED (completely)]Setting the pitch of an arrow?

Discussion in 'Plugin Development' started by Musaddict, Apr 13, 2012.

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


    I'm in the midst of upgrading my golfing plugin, and I need to force the pitch of each arrow according to which club I'm using. The only problem is that it seems to be ignoring the setPitch() method.

    2. event.getEntity().getLocation().setPitch(GcClubs.getClubPitch(shooter));
    3. shooter.sendMessage("" + event.getEntity().getLocation().getPitch());

    My getClubPitch() method returns a float depending on which club they're using. In the player debug message, it returns the pitch of my camera, and the arrow's pitch is not changed.

    here's a snippet of my getClubPitch() method:
    2. public static Float getClubPitch(Player player) {
    3. int club = Club.get(player);
    4. if(club == 0){
    5. return (float) 46;
    6. }
    7. if(club == 1){
    8. return (float) 50;
    9. }
    10. return (float) 45;
    11. }

    thanks in advance!

    Fixed the problem (for now). What I ended up doing was saving the force of the bow, and multiplying it with the float for the Y vector.

    90° on the Y axis is +π, so if I wanted to set the angle for (club = 0) to 45° I would use (½π * force). Simple, ya?

    lol, now for more precise shots, I need to do the same thing for the X and Z axis...

    Good lord... took me WAY to long to figure it out.

    Hopefully none of you will have to either if you ever want to force the vector of a projectile solely based on the user's direction and bow force.
    2. Float force = GcClubs.Force.get(shooter);
    3. Float dirX = (float) ((0 - (Math.sin((shooter.getLocation().getYaw() / 180) * Math.PI) * 3)) * force);
    4. Float dirZ = (float) ((Math.cos((shooter.getLocation().getYaw() / 180) * Math.PI) * 3) * force);
    6. event.getEntity().setVelocity(event.getEntity().getVelocity().setX(dirX));
    7. event.getEntity().setVelocity(event.getEntity().getVelocity().setY(GcClubs.getClubPitch(shooter)));
    8. event.getEntity().setVelocity(event.getEntity().getVelocity().setZ(dirZ));

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 25, 2016
Thread Status:
Not open for further replies.

Share This Page