Help with Java scripts that will destroy objects when players collide with the object after 1 second.

Please help me !!!
Help with Java scripts or c# that will destroy objects when players collide with the object after 1 second.

I need for the platform game, so when a player steps on platform , platform destroy its self after 1 second and maybe play sound :slight_smile:

Thank you very much for your help I’ve tried everything but can not achieve this result.
I’m not a programmer, but a graphic designer and an artist who went into making the games so that my java and c # as a hobby. Gotcha something but not so much that it completely I write it correctly so dear people, help, and normally my bow to you to the floor. g.Miter

1 Answer

1

fails to solve the problem itself , and this is the solution :wink:

Step 1 : Create a cube and put it to the trigger

Step 2 : Create another cube that is going to be a platform and call it as vinegar , for example platforma1

Step3 : one cube uncheck mesh renderer

Step 4 : the second cube put this script and call the script as you want to.

pragma strict

var coinSound : AudioClip ;

OnTriggerEnter function (other : Collider )
{
if ( other.tag == "Player " )
{
audio.PlayOneShot ( coinSound ) ;
yield WaitForSeconds ( 2 ) ;
Destroy ( gameObject.Find ( " platforma1 " ) ) ;

}
}

mandatory platformu1 tagajte as platformu1

5 : Player must be taged as a player

6 : and now, at the end of the line at which you walk you put di fits a cube that is the trigger a little izdnad cubes at which you walk .

So it will trigger kill destroy the platform on which you walk and let the sound .

I hope that someone will help you. nice greeting g.Miter

Abridged version .


video link : http://www.youtube.com/watch?v=9I65B9u507o&feature=youtu.be

And this is java script:

#pragma strict

var coinSound : AudioClip;

function OnTriggerEnter (other : Collider)
{
if(other.tag == “Player”)
{
audio.PlayOneShot (coinSound);
yield WaitForSeconds (2);
Destroy(gameObject.Find(“platforma2playerwalk”));

}

}

Free download of Prefab :
http://wikisend.com/download/715290/PLATFORMA 2SEC.unity