Two gameObjects in same place [Problem]

Hello,

I created a house and the player can add objects inside this (instantiating prefabs), but the gameObjects appears in the middle of walls or in another gameObjects.

i tried this code:

function OnTriggerStay (other : Collider) { 
Destroy(gameObject);
}

But the object isn’t destroyed, still alive.

Thanx.

What you’re experiencing might come from colliders and rigidbodies. If you instantiate an object with a collider and a rigidbody, inside another object with a collider and a rigidbody, the two INTERSECT and tend to push eachother off.

To avoid this, place the prefabs on different layers (or use any such alternative), and use the layer collision matrix