- Home /
Object reference not set to an instance of a object -
im quite new to unity, heres my question , well it comes up with an error and says - Object reference not set to an instance of a object heartbeat.OnTriggerEnter(UnityEngine.Collider col) script--
var gameobject : GameObject;
var Seconds = 1.0;
var buildup : AudioClip;
function OnTriggerEnter(col:Collider) {
GetComponent(CharacterMotor).enabled = false;
audio.clip = buildup;
audio.PlayOneShot(buildup);
}
this script freezes the character, and is suppose to play a sound, but then the error comes up, ive used a script like this before for a popup, which worked, so any answers?:(
I formatted your code for you. You may care to learn how to do this by viewing the tutorial video linked to the right of this page.
Does your game object have a Character$$anonymous$$otor component?
In addition to the Character$$anonymous$$otor, the game object with this scirpt also needs an AudioSource component. For future posts, please include the error output from the console. It tells us which line is producing the error as well as the stack trace.
Your answer
