- Home /
Jumpscare script help!!
I have made a working script for a jumpscare, its attached to a cube for the moment. The script makes the cube appear when the player enters the trigger(the cube has a ghost image for now). But it's a quick scare so the ghost can't stay there for ever, so I also included some lines to destroy the cube after some seconds. My 2 problems are:
1) The object gets destroyed after some seconds after the game starts, so the countdown it's not starting when the player enters the trigger, i need that first the object appear, then half of a second and then gets destroyed.
2) It doesn't matter if I write 10, or 2.0, or 1.0 seconds, the object gets destroyed way to slow and the time doesn't change, even if I type different numbers, and the cube can't stay so long to make the jumpscare effective.
Here is the script, it's simple but it works so far, the only problem are those two things, please help:
pragma strict
var gameobject:GameObject; var Seconds = 1.0;
function Start() { gameobject.renderer.enabled = false; }
function OnTriggerEnter(col:Collider) { gameobject.renderer.enabled = true; }
function Update(){ Destroy(); }
function Destroy(){ yield WaitForSeconds(Seconds); Destroy(gameobject); }
Answer by JBoy · Sep 28, 2013 at 06:52 AM
This should do it ;)
var gameobject : GameObject;
var Seconds = 1.0;
function Start (){
gameobject.renderer.enabled = false;
}
function OnTriggerEnter (col:Collider){
gameobject.renderer.enabled = true;
Destroy();
}
function Destroy(){
yield WaitForSeconds(Seconds);
Destroy(gameobject);
}
THat worked!:), the only problem left is the time, with what you writed in that script (1.0) it takes about 10 seconds to get destroyed(way too long), and i need it to get destroyed in about half a second (0.5 seconds), what should i do? please help:)
Sorry, i already solved it out. Thanks it worked great and whas exactly what i was looking for:)