I have a question.
I have a camera and a direction.
I get the direction the player is facing and find a random position in the distance and I want to draw something there. But I don’t want it to be in front of the player all the time.
I want to get a new position instead of straight ahead, in an arc of 45 degrees from center of straight ahead at that random position.
This is a mess but hope it helps.
Step one get player position and direction.
Calculate a new position distance from player.
I want to take that new distance from player and get a vector3 based on a 45 degree arc -22 to 22.
This is a grid base game so the direction is verify simple, but I know you guys know how to do this in a generic form where it doesn’t matter.
From my understanding, you are trying to get a point between a reference point and another target and then rotate that point around the reference point in a 45 degree range and then retrieve the current position ?
Interpolate between the reference node (node.A) and the target node (node.T).
Create another new node (node.B), then set its location to the interpolation.
Add the new node (node.B) to the reference node (node.A)
Rotate the reference node (node.A), node.B will rotate with node.A around node.A center.
Retrieve the current position of node.B in the field.
Or else use the polar coordinate system if you want some troubles in which you will convert an angle to a coordinate, i have made something similar before on 2d stuff but i don’t have the enough knowledge to reproduce that on 3d stuff.
It will work, if you draw the right angle for the right vector component, as i recall, the angle is represented between the (Vx, Vy, Vz) spatial components with the norm (x, y, z) of the rootNode, you may want to eliminate y or z to keep it simple.
If you just want to pick a random point x distance away between +/- 24 degrees… then I’d just use Quaternion.fromAngles and then multiply that rotation by new Vector3f(0, 0, distance)
…add that to your current location and Bob’s your uncle.