Hey guys I am creating a simple car game for practice and I am trying to make it so that you can move the camera where you please while the car is driving. My problem is when I press play my camera automatically starts flipping forwards and it wont stop. Here’s my code:
using UnityEngine;
using System.Collections;
public class CarCam : MonoBehaviour {
public Camera useCamera;
public Transform trackObject;
public float rotateSpeed = 5.0f;
public float updownRange = 60.0f;
float verticalRotation = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float rotLeftRight = Input.GetAxis("Mouse X") * rotateSpeed;
transform.Rotate(0, rotLeftRight, 0);
float verticalRotation = Input.GetAxis("Mouse Y") * rotateSpeed;
transform.Rotate(rotateSpeed, rotLeftRight, 0);
}
}
Please help Answers are greatly appreciated.