How to set a projectile's vector based on Bow Force and Yaw only

Discussion in 'Resources' started by Musaddict, Apr 14, 2012.

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

    Musaddict

    Had to devise this, cause the setYaw() method seems to do nothing. Here's this if any of you need to as well.
    I put this in my ProjectileLaunchEvent.

    Code:java
    1.  
    2. Float force = 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);
    5.  
    6. event.getEntity().setVelocity(event.getEntity().getVelocity().setX(dirX));
    7. event.getEntity().setVelocity(event.getEntity().getVelocity().setZ(dirZ));
    8.  


    The hashmap "Force" stores the float from a bow's force in the EntityShootBowEvent, then repurposes it to define how large of a vector to create.
     
Thread Status:
Not open for further replies.

Share This Page