Advertisement
PEMapModder

Untitled

Mar 29th, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. Depends on how you would like to use the direction.
  2. Do you want to see the angle of the player? You can get the player's yaw and pitch (see http://en.wikipedia.org/wiki/Yaw_(rotation)#/media/File:Flight_dynamics_with_text.png for what yaw and pitch mean) by $player->yaw and $player->pitch (don't modify them, because that won't make the player rotate). I am not sure about where yaw starts counting, so you may want to do some tests to see (you need to use ($yaw % 360) because the yaw could be infinitely large). As for pitch, facing absolutely downwards is 90 degrees, and facing absolutely upwards is -90 degrees. Facing absolutely front is 0 degrees.
  3. Or do you want to see what is the coordinates of one block in front of the player (that includes vertical direction too)? You can use $player->getDirectionVector(). This function returns a Vector3 object which represents how much the player's x, y and z coordinates would increase (or decrease if they are negative) if he moves to his front for one block (the player's pitch would affect the value. This means, if the player is facing absolutely upwards, the Vector3 will have a value of x=0, y=1, z=0; and if the player is facing towards the x-axis horizontally, the Vector3 will be x=1, y=0, z=0. This is very useful, because you can ->multiply($multiplier) the Vector3 to make the player zoom forward for $multiplier blocks. Or etc. Thnk of your own uses. :)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement