Hello Everybody, I have a Unity5 error when I play and try the camera local rotation, the code is pretty the same still of the video but no works, here the error and the code.
NullReferenceException: Object reference not set to an instance of an object
CameraBehaviour.Update () (at Assets/Scrpits/ShootHoop/CameraBehaviour.cs:21)
using UnityEngine;
using System.Collections;
public class CameraBehaviour : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
float addRotationSpeed = 3.0f;
float mouseX = Input.GetAxis("Mouse X") * addRotationSpeed;
float mouseY = Input.GetAxis("Mouse Y") * addRotationSpeed;
transform.localRotation = Quaternion.Euler(0, mouseX , 0) * transform.localRotation;
Camera mainCamera = GetComponentInChildren<Camera>();
mainCamera.transform.localRotation = Quaternion.Euler(mouseY, 0, 0) * mainCamera.transform.localRotation;
}
}
Somebody happens too???
Thanks for the help!