- Home /
Reuse a collision
Whenever my character collides with an object i add a rigidbody to that object and i would like to reapply the same force it should have received with the collision so it reacts as expected.
This is my attempt so far, but force is way too much as all objects fly from the scene:
void OnCollisionEnter(Collision collision) {
if (collision.gameObject.GetComponent<Rigidbody>() == null) {
collision.gameObject.AddComponent<Rigidbody>().AddForceAtPosition(collision.impulse, collision.contacts[0].point);
}
}
I can't find the force made to get that collision, so i don't know how to replicate it properly.
Comment