Hey.
So what I'm trying to do is if the player steps on a button, a door will open.
Here's the script I'm using:
function Collider(OnCollisionEnter)
{
if(gameObject.tag == "Button");
animation.Play();
}
The button the player has to hit is tagged "Button".
Also, I animated the door in 3DS Max and have colliders set for both the button and door.
What needs changed?
Thank you! :)
Try putting this on the button, and make sure the collision 'trigger' button is set to true in the inspector
function OnTriggerEnter(other:Collider){
if(other.gameObject.tag == "player"){
animation.Crossfade("open");
}
}
1 Attach below script to your "Button" object
2 set player object's tag to "Player"
3 add colider to button and player( you can use character controller for player)
function OnCollisionEnter(collision : Collision) {
if(gameObject.tag == "Player");
animation.Play();
}