- Home /
Door like script
Hi all! I searched all over and I just couldn't find what I need. I want the Player of my game to be able to click on a door and open it, but only when he/she is in a trigger. I have this so far:
function Update ()
{
if ( Input.GetButtonDown("Fire1") ) {
animation.Play("dooropen");
}
}
but how would I make it only so it can be opened when the player is standing in the trigger? Can anyone link tutorials or script references? I'm been searching and just can figure this out. Thanks!
Answer by robertbu · May 16, 2014 at 02:55 AM
Check for Input.GetButton() (Not Input.GetButtonDown()), inside of OnTriggerStay(). You'll need some state so that you don't repeatedly call the animation.
Your answer
Follow this Question
Related Questions
how character's legs(tps) move? 0 Answers
How would you make a shapeshifting mechanic in a game? 1 Answer
Playing sprint animation with vertical axis? 0 Answers
How to fix Animation 1 Answer
Why isn't my animation being played? 0 Answers