Reputation: 10571
I have a child gameObject which contains a collider and rigidbody (kinematic+gravity =true) I want to throw it. For this reason i am just disabling the kinematic but object becomes fall down and not throwing. Actually I have a htc-vive controller who has a child cube that child cube i want to throw. For throwing:
first I make child cube's parent null
then, i false its kinematic property(so that i can throw it)
but object suddenly fall down.
Upvotes: 0
Views: 64
Reputation: 317
A gameobject with a rigidbody will apply the unity physics. If you set the kinematic to true the object will not move. When you disable the kinematic, the gravity is applied on the gameobject and fall down because doesn't have anything to collide with and stop from falling.
Edit:
public class ApplyForce: MonoBehaviour {
Rigidbody objRigidbody;
// Use this for initialization
void Start () {
objRigidbody = this.GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update () {
if(Input.GetKey(KeyCode.A)){
objRigidbody.AddForce(new Vector3(20.0f,20.0f, 20.0f));
}
}
}
If you attach this to your object, everytime that you press the key "A" you will apply a force of 20 in every direction. Hope it helps to understand how to do it on your own.
Upvotes: 0