- Home /
Question by
shortyzsly · Nov 29, 2013 at 09:46 PM ·
jumpobjectsforcehorror
Making objects jump into the air. Giving them sudden Force?
I have tried this code a few times to get a certain set of objects to jump into the air when i pass through 1 of the triggers and make a sound. A sort of. Jumpscare for my horror game. But it seems that when my player walks through the trigger. Nothing happens. I have avoided the gravity issue by applying the velocity directly and they are not on isKinematic either.
Here's the problem code.
var destroyTime = 0.1;
var forcesound : AudioClip;
var girllaugh : AudioClip;
var trigger1 : GameObject;
var trigger2 : GameObject;
var woodenBoxsGroup : GameObject;
function OnTriggerEnter (col:Collider){
rigidbody.velocity += transform.up * 10;
audio.PlayOneShot(forcesound, 0.9);
audio.PlayOneShot(girllaugh, 0.9);
yield WaitForSeconds(destroyTime);
destroy();
}
function destroy(){
Destroy (trigger1);
Destroy (trigger2);
}
Comment