How do I prevent my object from going through certain walls?

Hi

My FPS Player is going through some walls and not through others.

I want to make all walls solid.

I created this in C4D.

Thanks, Chris

I'm assuming you created your level geometry completely in C4D and then when importing ticked "generate colliders".

While this works well for quick tests and single complex objects, you should generally use simple colliders to mark up your scene in Unity. Not only are these much cheaper performance-wise, but also more precise. This also ensures that you know exactly what is going on in your scene physics-wise.

Approach:

  • Disable "generate colliders" for your geometry.
  • Add the geometry to your scene - of if it is already there, make sure that it has been updated to not have a mesh collider attached.
  • For each wall and other elements in the geometry hierarchy in the hierarchy view, attach a box collider (or one of the other simple colliders from the Components -> Physics menu and size it to fit with the element.
  • Profit!

Notice that it is a good idea to make the colliders a bit too "tick" - in case of walls you could just ensure that the excess collider is inside the walled up area. This helps make sure that the collider is respected by fast moving objects.

The only thing I can think of is that the normals on your collision geometry might be inverted from what you are expecting.

You will have to be more specific in order to get a more accurate answer, but I find that is a general problem I see upon receiving geometry from other artists during integration.

Cheers,

==

Sometime the speed of the player can be an issue...but is is also related with the TIMING your game use (Project/Time options) and also the physics.

Is your FPS player a rigidbody ?

Does it fall madly from big heights ?

Be more specific!

There is a script in the WIKI which use RAYCASTING for avoiding these problems, but usually, you won't need it.