| New Reply |
Finding the position directly behind a player |
Share Thread |
| Jan22-13, 09:52 PM | #1 |
|
|
Finding the position directly behind a player
I'm attempting SCIENCE by using math that I have never used before, nor do I understand (despite reading numerous articles, watching all of the khanacademy videos, etc etc)
I'm attempting to use trig to locate a point directly behind another player in Minecraft. I've read through these three pages: http://stackoverflow.com/questions/4...-calculate-end http://en.wikipedia.org/wiki/Spheric...an_coordinates http://www.opentk.com/node/2505 and have come up with this code: Code:
double dEntityDistance = getPlayer().getDistanceToEntity(player); double dNewX = /* The current player */getPlayer().posX - dEntityDistance * Math.sin(Math.toRadians(/* The player we want the position behind */ player.rotationYaw % 360)) * Math.cos(Math.toRadians(-player.rotationPitch)); double dNewZ = getPlayer().posZ - dEntityDistance * Math.cos(Math.toRadians(player.rotationYaw % 360)) * Math.cos(Math.toRadians(-player.rotationPitch)); |
| Jan23-13, 10:59 AM | #2 |
|
Mentor
|
Behind relative to what? The plane, or the direction the player is looking to?
As a first step: Do you understand how Minecraft stores the orientation of the player? The definition of those parameters should give you a direct way to calculate x,y,z in front of the player. Behind is just the same, but with opposite signs for the distance. Comments directly in formulas? Really? |
| Jan23-13, 04:00 PM | #3 |
|
|
|
| Jan24-13, 12:10 PM | #4 |
|
|
Finding the position directly behind a player
I fixed this. Minecraft rotations are completely back-asswards, and it took me a while, but I now can successfully teleport behind other players.
|
| New Reply |
Similar discussions for: Finding the position directly behind a player
|
||||
| Thread | Forum | Replies | ||
| If we arent directly evolved from chimps, how are our dogs directly evolved wolves? | Biology | 12 | ||
| finding position vector | Calculus & Beyond Homework | 1 | ||
| When the sun was directly overhead in syene, why was it not directly overhead in alex | Introductory Physics Homework | 10 | ||
| Basketball player shooting ball, finding velocity for a no backboard shot | Introductory Physics Homework | 2 | ||
| is reality single-player or multi-player? | General Discussion | 13 | ||