- Home /
how to determine if two objects are occupying the same space?
I am making a building mechanic in my game, i need the game to recognize when one object is inside another WITHOUT using a rigid body. I have already tried using OnCollisionEnter(). If anyone could help me with this that would be great.
Answer by tormentoarmagedoom · Oct 09, 2017 at 07:45 AM
Good day @unity431 !
The "way" to detect this colissions is with the OnCollisionEnter or OnCollisionStay. But as you know, this needs at least 1 Rigidbody in one of the objects. Why you dont want to use Rigidbody?
I think the best solution is: Create in the object you are placing a Rigidbody component, and if the position is correct (no collisions detected) , delete the Rigidbody component.
Another solution (but not very good if a lot of objects) can be done by knowing the position of all objects and the areas they are in. This way you can check 1 by 1 all objects if one area is inside the area of the new object or calculate the distance betwen threm...But as you can imagine, this solution is not very "efficient".
As i said, Why you dont want to use Rigidbody?
Bye :D
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Object following a path and colliding with other objects with physics. 1 Answer
Any way to ignore collision between rigidbodies and colliders/character controllers? 1 Answer
I am not able to call a function from OntriggerEnter event :( 2 Answers