Moving through colliders

So I’m having trouble with collisions. The collision is triggering, but when the object is moving faster, I go right through it. I had this problem in the TileVania section of the 2D course and just had to make the player movement slower than I wanted. I’ve tried changing the collision detection to dynamic, but that doesn’t seem to make a difference to me. Any other solutions?

Side Note: I keep trying to upload a gif of the gameplay, but it just appears as a 1x1 green pixel.

Hi NateStC, I think the problem is your object is moving so fast it gets translated past the collider so no collision is taking place.
A possible solution could be using a ray cast from where the object is to where it will jump to next.

I hope that helps

I figured that it was just too fast, it’s just annoying because I don’t feel like I’m going that fast. I know I’ve had to cap FPS at 60 on some games (like Skyrim) because the physics engine can’t keep up. Maybe that has something to do with it too?

Hi Nate,

Unity cannot handle the collision between fast moving objects well. The physics simulation is highly optimised. What you could do at the expense of the performance is to set the Collision detection mode of the player’s Rigidbody2D component to “Continuous”. In the Physics2D settings, you could also tweak a few values.

To optimise the performance, you could enable “static” in the Inspector of each game object that has got a collider attach and will never move during runtime. Do not enable “static” on moving colliders because that’ll have a significant negative impact on the performance.

Don’t worry too much about the performance because this game is fairly little. It is relatively unlikely that you’ll notice any lags unless you use too high values in the Physics2D settings. Tweak the values, increase them slightly until you are happy with the result.


See also:

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms