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 );
}
}