Is there anyway to make an object impenetrable?

I’m using OnTriggerEnter on the game object the user is controlling, so the game object itself is a trigger so that it can destroy other things in its path upon collision. The problem is that I don’t want the object to be able to destroy, or go through walls. I figured out how to not destroy the walls but now the game object can just go through them. Is there anyway to avoid this by either making the walls impenetrable or any other way? Thanks!

Seems like you worked out how to not destroy objects that shouldn’t be destroyed. I was going to suggest making destructibility an object property. You could implement this as a tag, for example, that your destruction code tests for.

On solving object penetration: This is only well-handled automatically by moving rigid bodies and character controllers. Even then, if you use movement by translation, you’ll often have colliders inter-penetrating (intersecting for one or more frames). Unity resolves this by pushing the colliders apart. The physics engine for regular collider movement by rigidbody.AddForce (or by character controller Move) does a pretty good job of keeping objects from inter-penetrating. However, it does not prevent fast moving objects from passing through thin objects if they are one one side of the wall on one frame, but on the other side of the wall the next frame.

This may be avoidable in your game by thicker walls, slower movement, and/or faster physics framerate. If not, the most precise solution then is to test for collision of the solid created by the object at its current position projected through to its position on the next frame. If this project volume collides with the wall, then you can run a more involved evaluation to determine where the object should stop.

Unity provides some built-in tools to resolve this if you’re willing to simplify. You can use Physics.Raycast, Spherecast, or Capsulecast (use whichever is the simplest you can get away with or best fits the mesh of your moving object) ahead of the moving object to see where a collision will occur. See Physics. Provided you’re casting (projecting) far enough, it will see any wall collision point before it would be possible to move beyond the wall by the next frame. You can then handle this collision using details from the RayHitInfo out parameter.