--> need some HELP with a little script <--

Hey guys!

I’m very new to scripting :? and I wanna make a script for a grenade (a simple sphere), that rolls over the terrain and will only explode if it touches the player.

looking forward for responses :slight_smile:

Try this:

var explosion : GameObject;

function OnCollisionEnter (collision : Collision)
{
     if (collision.collider.name == "Player")
          BlowUp ();
}

function BlowUp ()
{
     if (explosion)
          Instantiate (explosion, transform.position, transform.rotation);
     
     Destroy (gameObject);
}

works great, thx a lot!!