Parented camera to Headbone of my model but dont want it to be affected by it's Z rotation
Every time the walk animation starts the model's head tilt a bit to the right but i dont want that effect on my camera. The camera is a child of the forehead of my model.
using UnityEngine; using System.Collections;
public class camMouseLook : MonoBehaviour { [SerializeField] private GameObject character; Vector2 mouseLook;
public float sensitivity = 5.0f;
void Update()
{
var md = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
transform.localRotation = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
character.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, character.transform.up);
}
}
It's used for a fps shooter so i want to be able to lean left and right and tilt the camera then so i dont want to completely lock the Z rotation for all animations.
Your answer
Follow this Question
Related Questions
How to access child animator parameters from a parent's script 0 Answers
Character buggs out and goes missing off screen 0 Answers
Camera child to animated object does not work 1 Answer
Child object in animation transform Problems 1 Answer
How to disable the animation of the child game object? 0 Answers