# Physics but without displacement

How can I have physics where enemies and players collide but don’t displace one another?

I am using simple capsule colliders for each enemy and player - but when a player does something like “leap” or “teleport” it’s possible they could target a position “inside” the enemy capsule collider.

The current behavior will cause the enemy to be displaced from it’s existing position (e.g. moved to the closet position so that the player is no longer inside their collider). But in those cases I want the player to not move the enemy, but just be “inside” until someone moves away. It looks janky when players can move enemies by leaping on them

What should happen in this case? Or better asked, why do you need physics at all in this case?
You can always use collider as trigger only, this means no collision effect is happening, but you can still catch a collision in code.

1 Like

I still want to have collisions between the player, enemies, and environments. There’s some physics based spells like a “force push” that can knock enemies against things and they bounce off other enemies or walls.

It’s mainly when abilities like a teleport or charge are used where the player collider can sometimes end up “inside” the collider of an enemy. For charge it might end up inside an enemy because it allows players to “charge” through enemies, and during the charge the players collision is disabled with the enemies. When it gets re-enabled is when the “displacement” happens.

I think one way I could solve this is during the teleport/charge I put the player on a different physics layer that has no collision with enemies, and then after it can check whether it’s inside an enemy collider. If it is, then it will wait until the player exits the enemy collider before moving the player back to the normal physics layer. But I wonder if there is a better or simpler way to achieve this

There are a few ways to ignore collisions:

The layer collision matrix: Unity - Manual: Physics

And colliders also have layer exclude lists in the inspector.