- Home /
Question by
bradleyellis2005 · Apr 07, 2020 at 07:44 AM ·
rotationmovementanimatormousepositionroot motion
My walking animations root motion has a problem when my mouse look script is being used?
I have added a 3rd person based mouse look script to my camera which is a child to my character everything works with looking around and that. But my character does not move properly(the animation plays fine but it must be something to do with the root motion). Furthermore, I have disabled the mouse look script and then the player walks fine. Thanks in advance. Here is my mouse look script:
{
[SerializeField]
private Transform playerRoot;
[SerializeField]
private float sensivity = 5f;
[SerializeField]
private Vector2 default_Look_Limits = new Vector2(-70f, 80f);
private Vector2 look_Angles;
private Vector2 current_Mouse_Look;
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
void Update()
{
LockAndUnlockCursor();
if (Cursor.lockState == CursorLockMode.Locked)
{
LookAround();
}
}
void LockAndUnlockCursor()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
if (Cursor.lockState == CursorLockMode.Locked)
{
Cursor.lockState = CursorLockMode.None;
}
else
{
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
}
} // lock and unlock
void LookAround()
{
current_Mouse_Look = new Vector2(
Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"));
look_Angles.y += current_Mouse_Look.y * sensivity;
playerRoot.localRotation = Quaternion.Euler(playerRoot.transform.rotation.x, look_Angles.y, playerRoot.transform.rotation.z);
}
}
Comment