It is actually really easy. this function will return a vector in the direction you are pointing in, assuming you have a yaw and pitch value(you can't just get it from a single coordinate, you need some sense of direction too):
1 2 3
| Vector3D getDirectionVector() { return new Vector3D(-Math.cos(pitch * Math.PI / 180.0) * Math.sin(yaw * Math.PI / 180.0), Math.sin(pitch * Math.PI / 180.0), -Math.cos(pitch * Math.PI / 180.0) * Math.cos(yaw * Math.PI / 180.0)); } |
Note: This is assuming yaw and pitch are in degrees.
Tell me if it didn't work, might've messed up something there.
Then after that, you can use ray tracing or some other good method to find the object(s) you're pointing at.
