Created
July 19, 2012 10:10
-
-
Save md-5/3142861 to your computer and use it in GitHub Desktop.
REl move code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Moves the specified amount forwards and left in the current direction | |
* (calculated based on current yaw) | |
* | |
* @param forward, double sideways how far to move | |
* @param left how far to the left to move | |
*/ | |
public void moveRelative(double forward, double left) { | |
final float yaw = getLocation().getYaw(); | |
final double xToMove = forward * Math.cos(yaw) - left * Math.sin(yaw); | |
final double zTomove = forward * Math.sin(yaw) + left * Math.cos(yaw); | |
getLocation().setX(getLocation().getX() + xToMove); | |
getLocation().setZ(getLocation().getZ() + zTomove); | |
// | |
sendLocationUpdate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment