I am created a top-down shooter and i have the player rotate towards the mouse...i have a script attached to the player to instantiate a grenade to be thrown when the mouse button is clicked. The grenade shoots BUT just drops right to the ground, no force is applied once its instantiated...here is my code...
var speed = 40;
var cratePrefab:Transform;
//static var canShoot = false;
function Update()
{
if(Input.GetButtonDown("Fire1"))
{
//only shoots if player has ammo
if(Collisions.GRENADE_AMMO > 0)
{
Collisions.GRENADE_AMMO -= 1;
//GameObject.Find("g_count").guiText.text=""+Collisions.GRENADE_AMMO;
var crate = Instantiate(cratePrefab,GameObject.Find("shootpoint").transform.position,Quaternion.identity);
crate.rigidbody.AddForce(Vector3.forward * speed);
}
}
}
all help is greatly appreciated!!