Static object colliding

Hi I need to know if two static objects are colliding when the code is first ran.
I tried setting:-

Rigidbody rig = GetComponent<Rigidbody>();
rig.sleepThreshold = 0.0f;

But OnCollisionEnter or OnCollisionStay are never called.
This objects do not move in game, it’s just to check a collision on the first frame.

How do I do this? I’ve tried using a trigger, but I need the collision points that I get with colliders.
Can anyone help?

Sorry, but static objects can’t detect anything.

Static objects by definition are static and do not move so they don’t detect any collisions. They sleep and let the live non-static rigidbodies handle collisions. Maybe you’re looking for Kinematic?

The Scripting Reference have examples on how to handle collisions.

Thanks, I haven’t set them as ‘static’ in the editor. It was an unfortunate wording on my part, sorry.
They just start off colliding, and I wanted to detect the collision point. I’ve even tried giving them a vertical velocity, but they have to be all the same to keep them together.
I think I’m going too give up and do my own detection code, it’ll be neater anyway.

OnCollisionEnter() works extremely well. It doesn’t get any cleaner than that. Check out the example in the Scripting Reference.

Thanks, it’s not getting called though, and I have rigid bodies and velocities on everything. I guess if they start off colliding then it never calls the function. Or the Stay function.

Yes, I believe if they start in a collided state then you’ll have some issues from the bad initialization of the rigidbodies.

Yeah, I’ve seen that behaviour in other game engines. I’ve just realised I need it to work in edit mode anyway. :slight_smile: