in my script i get a NullReferenceException: Object reference not set to an instance of an object
dangerzone.Awake () (at Assets/Levelkit 1/FPSScripts/dangerzone.js:5). the script is a trigger box collider that when it hit the player it will take you 5 point of life .the script works fine but i always see this error and i suspect that it my be the reasons why my game lags
here is my script:
#pragma strict
var healthScript : healthscriptforplayer ;
var animator: Animator;
function Awake () {
healthScript = GameObject.Find("First Person Controller ").GetComponent( healthscriptforplayer );
}
function OnTriggerEnter (Col : Collider ) {
if ( Col.tag == "Player"){
animator.SetBool ("Nattack" , true);
animator.SetBool("Nwalk" , false);
healthScript. CurrentHealth -= 5;
}
}
function OnTriggerExit (Col : Collider ) {
if ( Col.tag == "Player"){
animator.SetBool ("Nattack" , false);
}
}
please help.