Fast lasers not working with collisions?

I’m trying to develop a space sim similar to freelancer.

I’ve noticed that when firing at a cube in space (which I use for collision testing) sometimes the laser don’t hit the front face of the cube but it hits at the back, and sometimes the laser just goes through the cube.

After trying different combinations and param values for the colliders and rigidbodies I found that if I slowed down the lasers it always worked fine.

I’m attaching some videos to make this more clear. Is it possible that if a projectile is too fast then unity doesn’t get to detect the collisions? Thanks.

184938–6555–$fastlasers2_132.zip (853 KB)
184938–6556–$fastlasers_107.zip (1.02 MB)
184938–6557–$slowlasers_537.zip (1.03 MB)

The speed determines the movement distance per frame. The collisions are calculated after the movement. As such, you can theoretically have a bullet move so fast it passes through the target.

To avoid this, use a raycast from the front of the projectile that checks the distance it moves per frame ahead of itself. If the raycast hits something, make it perform a collision by script instead of by physics engine.

The above technique works fine for fast projectiles, but it doesn’t look natural on the slower ones.

I see, thanks. :slight_smile:

There is a script on the wiki doing just that.

YES! awesome, It worked great! thanks a lot