- Home /
Collision impact based on direction and speed
My game has spheres that move by rotating on their axis.
I want to calculate the impact of these balls colliding with each other, similar to how you might calculate 2 cars crashing together.
I have searched the forums and found bits and pieces like getting the contact.normal and col.relativeVelocity.magnitude.
My problem is that I can't find any way to find the direction the spheres are travelling.
Here's an example of what I want to happen:
Sphere1 is stationary, Sphere2 is speeding towards Sphere1 and collides with it Sphere1 should take significantly more damage than Sphere2 because Sphere1 is sitting still
If Sphere1 was moving towards Sphere2 at half the speed, then Sphere1 should still take the most damage, but Sphere2 would also take some damage.
If Sphere1 hits Sphere2 from the "side"(relative to it's direction) Sphere2 should take extra damage.
I was thinking that maybe I could just reduce the damage to the Spheres based on how fast they are going (Speed also increases armour or something), but there must be a better way!
Hopefully I explained this properly, appreciate any help!
Silly me I didn't realise that rigidbody.velocity actually returns a vector3 which will give me both the direction and speed to work this out. Now I just need to work out how to calculate the angle of impact..
Your answer

Follow this Question
Related Questions
Slerp look at direction not working... 3 Answers
Change direction on collision problem 4 Answers
destruction on impact 2 Answers
Game object collapsing/ going out of shape on impact from other objects. 0 Answers