Hello
I need a camera floating over the xz plane parallel to it.
The following script is only half ok:
transform.position += transform.forward*moveSpeed*Input.GetAxis("Vertical");
transform.position += transform.right*moveSpeed*Input.GetAxis("Horizontal");
Because the vertical axis is directed parallel the cameras direction vector, thus it won’t float over the plane but gets closer or farther to it, since the vector has an y component.
Translating with (x, 0, z) changes the lookat angle. I think moving the origin of the cameras direction vector would solve the problem, but I don’t know how to do it.
Or in need to follow a completely different approach?
Try making a Physics.Raycast at the ground every step to find your altitude, and adjust accordingly! If it sounds like what you need, I can make a more complete answer in a bit when I have more time.
– syclamoth