I have a field of view for a guard and I want it to rotate to mimic that the guard is looking around but I’m having trouble trying to figure it out. I’ve looked around and found LookAt, and LookRotation but both of these do that same thing they change the x, and y values but not the z value.
It is difficult to provide an answer as we don’t know in what orientation your objects/transforms are.
For example, if your transform is facing in the z-direction, that is the transform.forward.
In this case you can set transform.forward = targetPos.normalized
On line 5, targetPos is actually misnamed. That is the displacement between target and current. If your normalize the vector, the vector is then the direction of the target (from local)
I did the changes you suggested and it fixed the rotation x, and y values now they are both 0. Only rotation z changes but it’s still not rotating. It gets a value and stays at that value. I try to change it and the value reverts back to it.