- Home /
Question by
Admiral_Baggins · Dec 25, 2018 at 01:16 AM ·
camerafpsfirst-person-controller
First Person Camera Not Spining Player
I watched a YouTube tutorial, about how to create a fps controller. Everything worked fine, except the player doesn't spin. The code looks like this:
Vector2 mouseLook;
Vector2 smoothV;
public float sensitivity = 5.0f;
public float smoothing = 2.0f;
GameObject character;
void Start () {
character = this.transform.parent.gameObject;
}
void Update () {
var md = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
md = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * smoothing));
smoothV.x = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
smoothV.y = Mathf.Lerp(smoothV.y, md.y, 1f / smoothing);
mouseLook += smoothV;
transform.localRotation = Quaternion.AngleAxis(-mouseLook.y, Vector3.right);
character.transform.localRotation = Quaternion.AngleAxis(mouseLook.x, character.transform.up);
}
When the camera moves around the player should turn, but it doesn't. Any help would be appreciated, thanks.
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612184529im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
FPS Camera Position full Body 0 Answers
Enabling and siabling first person controller 0 Answers
Camera smooth transistion 2 Answers
Keyboard / Mouse control for FPS 0 Answers