How to create a rigid body cube that a player can push, but the cube can not block or hinder the player's motion?

Long story short: I’m working on a multiplayer game where there should be debris with rigid body on the client-side. The debris shall be able to get pushed/moved by objects and effects, but the debris shall not be able to block or hinder any movement - the debris is just there for the visual effect.

For example, if a player is moving into a “box” debris, the box should just be pushed aside/forward as a normal rigid body would, but the box should not hinder or slow down the motion of the player. Even when pushed into a wall the player should rather move through the box than getting blocked by it. If a projectile hit the box, the box should fly but the projectile remain unchanged.

What is the easiest way to achieve this? Is it enough with some layer and rigid body setup or does it require some more extravagant solution?

I was thinking about putting “debris” in its own layer and remove collision with e.g. players/projectiles, and instead add scripted effects to players/projectiles(or the debris rather) that will add some physics effects to the debris on collision trigger / raycast.

I think you are on the right track with your suggestions. The trouble is that if your player is a non kinematic rigidbody, there is no way to prevent collision forces acting on it when it hits the debris, if the debris is also a rigid body.

.

One solution would be to not use physics for your player character etc (use a kinematic rigidbody or some other manual solution for movement). This would mean that the rigidbody debris would get moved by the kinematic player, but the kinematic player is not affected by physics.

.

If you went the route of using layers you could certainly detect things overlapping the player with overlapSphere or similar, and apply a force, this might be the most straightforward solution. Another option would be to create an invisible “dummy” of the player in the same layer as the debris, and continuously move it to the current player position, and then the dummy could collide with the debris.