- Home /
Question by
MallardSam · Mar 31, 2017 at 02:44 PM ·
1st person
I'm trying to make a first person camera for my game but..
I've made a first person view for it and the camera rotates and everything there's just one problem, if i move it enough the camera rotates A little bit of of sink and its really annoying
Note:It starts out straight. Here's my code
using UnityEngine;
using System.Collections;
public class CameraAngleF : MonoBehaviour {
public float mx = 0;
// Update is called once per frame
void Update () {
float cx = mx * Input.GetAxis ("Mouse X");
float cy = mx * Input.GetAxis ("Mouse Y");
if (Input.GetKey (KeyCode.Mouse1)) {
transform.Rotate (0.0f, cx, 0.0f);
transform.Rotate (cy, 0.0f, 0.0f);
}
}
}
i want it so the it go's straight like this : not diagonal. 
Comment
transform.rotation = (transform.rotation.x, transform.rotation.y, 0.0)
This wont work as it is. Its just to give you the concept.
Answer by Firedan1176 · Mar 31, 2017 at 03:38 PM
Simply set the z coordinate of your transform.eulerAngles to 0.
Can you be more specific on how to use this for my project?
Your answer