Hi guys!
I’ve been trying to figure this out for a few hours now (over days).
I have a head that is essentially a camera that rotates to look where the player moves their mouse (like any FPS). What I want to do with that, is slowly rotate the characters body to match the Y rotation of the head.
I’ve tried all sorts of things like disconnecting the head from the body (as far as parenting goes) which works better, but with this code, what happens is if I move the mouse just a little to the left or right, the body continuously rotates at a speed based on the difference of rotation, rather than rotating towards the rotation of the head.
void RotateTowardsMouse(){
float rotX = this.gameObject.transform.rotation.eulerAngles.x;
float rotY = this.gameObject.transform.rotation.eulerAngles.y;
float rotZ = this.gameObject.transform.rotation.eulerAngles.z;
float camrotY = Head.transform.rotation.eulerAngles.y;
float newRotY = Mathf.Lerp (rotY, camrotY, 1f);
Vector3 newRot = new Vector3(rotX, newRotY, rotZ);
this.gameObject.transform.Rotate(newRot);
{
It’s probably obvious, but I don’t know what I’m doing wrong. Anyone have any solutions?