Rotate stop.

I am making scripts for a Grenade and I made it spin in the air but i spins when it hits the ground also. How can I stop this?

Here is my codes:

Attached to the grenade:

var contactPoint : Vector3;
var contactNormal : Quaternion;
var explosion : Rigidbody;

function OnCollisionEnter (collision : Collision)
{
var pie = false;
contactPoint = collision.contacts[0].point;
contactNormal = Quaternion.FromToRotation (Vector3.up, collision.contacts[0].normal);
Invoke (“Explode”, 5);
}

function Explode ()
{
Instantiate(explosion, contactPoint, contactNormal);
Destroy( gameObject );
}

Also attached to the Grenade:

function Update ()
{
transform.Rotate(5, 0, 5);
}

Attached to the launcher:

var projectile : Rigidbody;
var speed = 20;

function Update ()
{
if( Input.GetButtonDown( “Fire1” ) )
{
var instantiatedProjectile : Rigidbody = Instantiate(projectile, transform.position, transform.rotation );

instantiatedProjectile.velocity =
transform.TransformDirection( Vector3( 0, 0, speed ) );

Physics.IgnoreCollision( instantiatedProjectile. collider,
transform.root.collider );

}
}

Well, that doesn’t really make sense. When the grenade hits the ground, it should explode correct? And in explode() it destroys the gameobject, so what’s left spinning? Aside from that, just put some sort of if statement in there that checks to see if it’s colliding with something and don’t spin when it is. Like this…

function OnCollisionEnter (collision : Collision)
{
var pie = false;
//Add a new var
var colliding = true;
contactPoint = collision.contacts[0].point;
contactNormal = Quaternion.FromToRotation (Vector3.up, collision.contacts[0].normal);
Invoke ("Explode", 5);
}

function OnCollisionExit()
{
colliding = false;
}

function Explode ()
{
Instantiate(explosion, contactPoint, contactNormal);
Destroy( gameObject );
}

Also attached to the Grenade:


function Update ()
{
if(!colliding)
transform.Rotate(5, 0, 5);
}