- Home /
Unexpected token: if
i need some help to make this script work please :/
pragma strict
var falldoor : GameObject;
function OnTriggerEnter(other: Collider)
if(col.gameObject.tag) == ("Player"); {
falldoor.animation["falldoor"].speed = 1.0; falldoor.animation.Play();
}
function OnTriggerExit(other: Collider)
if(col.gameObject.tag) == ("Player"); {
falldoor.animation["falldoor"].speed = -1.0; falldoor.animation.Play();
}
Answer by hamcav · Mar 13, 2014 at 08:55 PM
You have to learn programming syntax. I found 3 error and this only in your if statement !!
 var falldoor: GameObject;
 
 function OnTriggerEnter(other: Collider){
   if(other.tag == "Player"){
      falldoor.animation["falldoor"].speed = 1.0;
      falldoor.animation.Play();
   }
 }
 
 function OnTriggerExit(other : Collider){
    if(other.tag == "Player"){
      falldoor.animation["falldoor"].speed = -1.0;
      falldoor.animation.Play(); 
 }
 
 }
thanks, but now when i enter the trigger and exit is says
NullReferenceException falldoortriggerscript.OnTriggerEnter (UnityEngine.Collider other) (at Assets/falldoortriggerscript.js:7)
NullReferenceException falldoortriggerscript.OnTriggerExit (UnityEngine.Collider other) (at Assets/falldoortriggerscript.js:14)
Obviously the script couldnt find the animation. Did you assign an animation to falldoor gameobject? From the editor i mean where you drag and drop.
If so you could try a debug like this:
 function OnTriggerEnter (other: Collider){
 if(other.tag == "Player"){
   if(falldoor == null)
     Debug.Log("No animation found");
     return;
   falldoor.animation["falldoor"].speed = -1.0;
   falldoor.animation.Play();
 }
 }
 
i did assign the falldoor on the trigger object right under the script, still whont work
Your answer
 
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unexpected Token 3 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Shooting at ground 1 Answer
Complicated request for script/help/explanations etc. 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                