Why does my player go right through the walls?

I have all of the collision enabled, and it stops at the wall when i set my speed to 10, but if i change it to speed 20 (a faster more perfered speed for this object), it goes right through the objects as if there was no collision. also, at speed 10, it still goes through the edges of the corners of the map i’ve created.

3 Likes

Hi lily_neko,

We use transform.Translate to move the game object. This does not take the physics simulation into consideration. If the speed is too fast, we override the values calculated by the physics simulation in a significant way.

If you want to challenge yourself, you could try to implement the AddRelativeForce method in your game. If you do that, also take a look at the example here.

The same happened for me and I found this thread in a Unity forum: Link here

In Unity 2020 go to Edit -> Project Settings -> Physics to make essential tweaks to Physics settings.
For me, what worked was to change the Default Max Depenetration Velocity. This is like the force that the collider pushes back against the item colliding into it. My issue was that I used a Rigid Body vs a Static Collider (Capsule). Because the Default Max Depenetration Velocity was set to just 10, my high-speed object was passing through the collider. I changed to 1000 and the collider became much more aggressive towards the invader. All good now.

I hope this helps!

6 Likes

Thanks buddy

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

Privacy & Terms