I smiply want to align my character with a vector3 direction by rotating it only on the x and z-axis. I also wnat this to happen gradually.
I have tried numerous things but none of them seem to work.
Well I think this works. Could use a bit of tweaking but I hope it is a good start. Feel free to comment on my post so I can possibly help you more. Heres the script:
public float yRotation = 0;
public float lookSpeed = 1;
void Update () {
transform.localEulerAngles = Vector3.Lerp(transform.localEulerAngles, new Vector3(transform.localEulerAngles.x, yRotation, transform.localEulerAngles.z), lookSpeed * Time.deltaTime);
}
The yRotation variable rotates the look rotation so it looks towards a rotation from 0-360.