I know this question has been asked, but I can’t get it to fire right. I’ve read a few solutions, but can’t seem to work it out. I’m trying to cut controls for cinematic scenes with the first person controller.
Right now I have a wonky set up I think…
I have a script on both the camera and the player controller.
Camera Script
#pragma strict
function EnableControls(){
var CamControls = GetComponent.<MouseLook>();
CamControls.enabled = CamControls.enabled;
var PlayerControls: GameObject;
PlayerControls.GetComponent(DisablePlayerControls).EnablePlayerControls();
}
function Start () {
var CamControls = GetComponent.<MouseLook>();
CamControls.enabled = !CamControls.enabled;
}
function Update () {
}
The script on the Player controll
#pragma strict
function EnablePlayerControls(){
var MouseLook = GetComponent.<MouseLook>();
var Motor = GetComponent.<CharacterMotor>();
var Controller = GetComponent.<FPSInputController>();
MouseLook.enabled = MouseLook.enabled;
Motor.enabled = Motor.enabled;
Controller.enabled = Controller.enabled;
}
function Start () {
var MouseLook = GetComponent.<MouseLook>();
var Motor = GetComponent.<CharacterMotor>();
var Controller = GetComponent.<FPSInputController>();
MouseLook.enabled = !MouseLook.enabled;
Motor.enabled = !Motor.enabled;
Controller.enabled = ! Controller.enabled;
}
function Update () {
}
I created an animation on the main camera using the built in animation feature. I try to fire an event from the animation which is a function from an instance of the script on the player control.
Errors I get are…
-
NullReferenceException: Object reference not set to an instance of an object
DisableCameraControls.EnableControls () (at Assets/Scripts/MenuScripts/DisableCameraControls.js:12) -
AnimationEvent ‘EnableCameraControls’ has no receiver!
Thanks in advanced to anyone who can help me sort this out. Thanks guy