Stop static colliders from overlapping

So I currently have some code through which a cube with a static collider (no rigidbody) is following the mouse in 3D space through the use of Raycasting.

The problem is, if the point is close to a wall, the collider will intersect due to the wall also being a static collider. I understand that in order for collisions to work at least one object needs to be a dynamic rigidbody, but in this instance, giving either the cube or the wall a rigidbody doesn’t make sense as I don’t want either object to interact with physics. (I know kinematic rigidbodies don’t interact with physics, but they also don’t collide with non-dynamic rigidbodies, so that doesn’t help sadly).

Here’s a screenshot where the mouse is placed half way up a wall:

Is there any other way from stopping these two objects from overlapping?

I’ve got a similar problem. Right now I’m workin on an RTS game, but sadly I can place buildings into other buildings.

In theory we would just have to detect if there is another collider nearby and then stop our initial collider (in your case the box attatched to the mouse) to move any further into that direction. “OnCollisionEnter” only detects when a collider is already intersecting with our object.

sou again in theory, we would have to declare a radius on our initianl collider in which it looks for other colliders and then stop it from going there.

Your post sort of works as a rubber duck for me :smiley: While writing this I may have come to an Idea. I’ll report back as soon as possible with a fix.