- Home /
Question by
sandeepsmartest · Nov 30, 2012 at 08:53 AM ·
rigidbodygravityforce
adding force to an instantiated gameobject in required direction
hi to all thanks for unity .i got struck up in a scenario where flight has to drop some objects on to the ground such that user will give the force direction (up/down/left/right)so that the object has to fall in that respective direction.i applied rigid body to the object that has to fall(cubefall) and i applied force aswell bt its seems to be having zero impact on the object by the force function.
if(Input.GetKeyDown(KeyCode.O))
{
cubefall.rigidbody.useGravity = true;
Instantiate(cubefall,InstantiatedPlane[tank.planenomisile].transform.position,cubefall.transform.rotation);
}
//for the object to project up(force which drives the object //in upward direction and then should fall down
if(Input.GetKeyDown(KeyCode.UpArrow))
{
Instantiate(cubefall,InstantiatedPlane[Strela_Own_Tank.planenomisile].transform.position,cubefall.transform.rotation);
cubefall.rigidbody. AddForce(transform.up* 300,ForceMode.Force );
cubefall.rigidbody.useGravity = true;//as it has to fall down
//cubefall.rigidbody.velocity = transform.TransformDirection(new Vector3(0,10,0));
//cubefall.rigidbody.AddForce(transform.forward * 200);
//i tried with all the statements that has been //commented
}
thanks in advance.code snippet is appreciated.
Comment