Cheapest way to catch collisions on very fast moving objects...

Hey guys,

For our current project we need to catch collisions on objects that can be moving very quickly in opposite directions.

We're using non-kinimatice rigidbodies on both objects, one with a capsule collider and the the other with a box collider...

One object moves via translation, the other via velocity.

Most of the time this works fine, but It seems that sometimes an object can go straight through the other without colliding properly when both are at high speed.

Any suggestions on the cheapest way of solving this, is the only option to use continous dynamic collision detection on one of the rigidbodies?

Thanks in advance guys :)

more ▼

asked Mar 29, 2011 at 07:10 PM

avatar image

1k 57 52 65

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Maybe you find some enlightenment on the awesome DontGoThroughThings Daniel's script. From my brief experience, the new physics improvement on Unity 3, collisionDetectionMode, still doesn't work as good as this raycasting implementation. For sure, neither is 100%, but this was pretty close on my case:

This script uses raycasting to avoid the physics engine letting fast-moving objects go through other objects (particularly meshes).

So it solves the issue of "objects moving very quickly" in the very practical instance of crossing walls that it never should be able to. You could extrapolate this script into one able to detect another object moving really fast.

The problem exists even if you use continuous dynamic collision detection because fast moving objects can move so fast that they are too far apart from itself from one frame to the next immediate frame. It's like they teleported and no collision detection would ever be triggered because no collision existed, from each frame perspective, and thus from all calculations processed.

more ▼

answered Mar 29, 2011 at 07:40 PM

avatar image

2.7k 116 125 132

Nice one, thank you.

Mar 29, 2011 at 07:43 PM demize2010

The real issue comes when the wall is moving too :P Am currently trying to solve it

Jul 20, 2012 at 12:21 PM Izitmee
(comments are locked)
10|3000 characters needed characters left

A few years later...

I was just having the problem, and it occured when my code was:

GetComponent ().AddForce (transform.forward * 10);

Sometimes the collider would catch my bullet, and sometimes not.

When I changed it to:

GetComponent ().AddForce (transform.forward * BSpeed);

It works perfectly now and catches every bullet. It's best you have a constant speed float rather than an constant incrementation.

more ▼

answered Jul 13 at 02:15 AM

avatar image

155 6 11 45

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Mar 29, 2011 at 07:10 PM

Seen: 13835 times

Last Updated: Jul 13 at 02:15 AM