OnCollisionStay Problem & Needs Help

Hello im trying to create a building mechanism to my game. The building mechanism is done and works fine. But i’ve got an problem when i try to place the “building”. I have islands that have meshcolliders and a script attached to a cube thats trying to detect if the cube is colliding with a collider that is called “islands”. My mesh collider is named islands and has a non convex meshcollider on it. but the cube is not detecting it. Any idea why?

Here is the script that has the problem:

var buildControllerScript : BuildController;

function Start ()
{
	buildControllerScript = GameObject.Find("Main Camera").GetComponent(BuildController);
}

function OnCollisionStay (col : Collision)
{
    if(col.gameObject.name == "islands")
    {
        buildControllerScript.canPlace = true;
    }
}

function OnCollisionExit (col : Collision)
{
    if(col.gameObject.name == "islands")
    {
        buildControllerScript.canPlace = false;
    }
}

Hi,
on collision is linked to rigid bodies/colliders…
I believe you should use On trigger stay

make sure your building has a collider with trigger turned on.
Code remains the same just change oncollision to ontrigger and see if that works.

as a side note I would recommend using “tag” rather than “name” (don’t ask me why :slight_smile:

hope that helps,