Quantcast
Channel: Latest Questions by Griffo
Viewing all articles
Browse latest Browse all 94

Get hit direction from one gameObject hitting another

$
0
0
If I fire a gun (bullet) I use a ray cast (Ray.direction) to get the direction the ray was hitting the rigid body to add force. impactTarget = hit.rigidbody; impact = ray.direction * 12; I then add force to the rigid body thats been hit with impactTarget.AddForce(impact,ForceMode.VelocityChange); And all works well with the bullet because it's instant, if I use the Ray.direction for the RPG by the time it's reached the target the ray cast could be looking somewhere else. But how if I shoot a RPG (gameObject with small box collider) and hit the same rigid body do I get the direction of the RPG hitting from. ImpactTarget = contact.gameObject.rigidbody; impact = contact.?? I'm using for the collision detection function OnCollisionEnter(collision : Collision){ var contact = collision.contacts[0]; Thanks.

Viewing all articles
Browse latest Browse all 94

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>