Non-Rigidbody equivalent to OnTriggerEnter?

Hello, world.

I am currently working on an RTS-style project to expand my knowledge of Unity and C#. For building placement, I already have my selected building following my mouse’s position in three-dimensional space, set up a nice snap-to-grid feature, and can have buildings placed or canceled. However, I can not find a solution for the seemingly simple problem of preventing buildings from being placed in one another. I figured that I could simply try to detect if the bounds of the building I am going to place is intersecting the bounds of another building, but the only way I can find to do that is with OnTriggerEnter.

However, I don’t want these buildings to be necessarily affected by physics, outside of being colliders that things such as units can not walk through. Is there another way to check if my building bounds intersect one another? Or is it necessary for me to use Rigidbodies? (And if so, can I detect the OnTriggerEnter for a child object? The building script is attached to an empty object, which has a child object that includes the mesh and collider.)

AndyMartin’s idea of a temporary rigidbody seems to be the best. I have the rigidbody in the prefab, and I remove it upon placement. Now it works! Huzzah!

One object will need a rigidbody. Something cool that you could do is test the object that you are going to place by temporarily attaching a rigid-body to it. Have a script on all of the buildings with something like this:

//Place this on all the buildings
void OnTriggerEnter(collider other)
    //there will need to be something
    //that all of these objects are able
    //to notify of a bad position
    BuildingManager.BadLocation = true;

//making everything static to be easier for this demo

//Place this only on one manager object
public class BuildingManager : MonoBehaviour
    private static bool badLocation
    public static bool BadLocation
        set{ badLocation = value; }

    public static IEnumerator TestBuildingLocation()
        //... instantiate some kind of prefab
        badLocation = false;

        //... this will need to wait so that the other buildings have time to register the collision
        yield return WaitForFixedUpdate();

        if(badLocation == false)

Any moving object needs a RigidBody in order to have a collider. This is because RigidBody is responsible for knowing about motion and when colliders need to be checked. Its actually a lot LESS overhead then if you just had a Collider you were checking every frame.

If you set “isKinematic” then you wont be effected by physics forces. If you set the collider as isTrigger then its movement wont be stopped by other objects.