I have a player position, a pointer indicating the players view direction, a distance and a horizontal and vertical angle. I want to calculate a target position:
- that is distance away from the players position
- that, from the players view direction, is horizontal angle to the right and vertical angle up
It's about positioning a Hololens-Application UI in a sphere around the player. The UI should i.e. be 40 degrees to the leftand 20 degrees up from the players view direction.
Edit: Added image to clarify. Given is the Player Pos (pX|pY|pZ), the radius (= length of the black bold line) and both angles in degree.
I'm looking for how to calculate the UI Center position (x?|y?|z?).
RotateAround()
only works if you have a game object with a transform component attached. It works within this use case, since I'm manipulating a gameObject. But in another case, for example if you want to shoot a raycast in the calculated direction, instantiating a gameObject for the purpose of manipulating it's position to calculate the target direction is not the right way. So while I'm very happy with the answer provided by you and CaTs, I've wanted to add the math way for the sake of completeness. I agree, the posted solution is not Unity-specific. But I didn't know that before. – Jonas Zimmer