- Home /
Respawn script and door animation help
Hey there I have a respawn script and a door animation script, I'm wanting my door to close when the character controller or 'PLAYER' falls into the water an respawns, I thought I had it and I can't see any problem with it but the door doesn't close, can anyone see any problems with this script?
Respawn Script
function Update () { if (transform.position.y < 951.6485) { transform.position.y = 957.5119; transform.position.x = -38.58647; transform.position.z = 7898.044; died = true; } }
Door script
var animateobject: GameObject; var open : boolean = false; function OnTriggerEnter (collision : Collider)
{
if (collision.gameObject.tag == "PLAYER"){ if(open==false){ animateobject.animation.Play ("DoorOpen2"); open = true; if(open==true){ yield WaitForSeconds(10); animateobject.animation.Play ("DoorClose2"); open = false; } } } } function Update(){ if(Respawn.died==true){ animateobject.animation.Play ("DoorClose2"); Respawn.died=false; } }
Oh and if anyone can suggest a script to make a 10 second timer appear on the game camera when the door is triggered to open that would be great.
James
Your answer
![](https://koobas.hobune.stream/wayback/20220613101752im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animation clip does not exist? 1 Answer
Trigger door animation with external trigger 1 Answer
Door Movement Animation 3 Answers
Animate Doors and Button Through Script 1 Answer
Need help with my animation script 2 Answers