Hi have code that i used to look at the mouse position, it works fine, but its a bit snappy, I want it to be more smooth. I have looked into different ways and encountered stuff with quaternions which I have tried out to my ability, but I dont really understand it. Could anyone help with a way I could change this code so it would be smoother. It should only rotate around the Y axis
You can use Vector3.Lerp which interpolates between 2 Vector3 using a third argument which is Time.deltaTime * lookSpeed makes it slowly transition in time from point A to point B, making sure that it stays framerate consistent.
in start :
Vector3 previousLookAt = new Vector3 (look at coords);
Vector3 currentLookAt = previousLookAt;
in update :
currentLookAt = new Vector3 (look at coords);
transform.LookAt ( Vector3.Lerp ( previousLookAt, currentLookAt, Time.deltaTime * lookSpeed ) );
previousLookAt = currentLookAt;
you should look into Mathf.Lerp, Vector3.Lerp and Quaternion.Lerp / Slerp
Thanks for the answers, trying them out just now. Hopefully one will help with what I am looking for