Collision confusion

i used a box around a certain area to detect whether the player is within that area or not. i’m trying to check if the player is within that box to do some other coding stuff, but i can’t turn on the collider because it stops the player from entering the box. i tried the below code and it just brought up errors out the wazoo.

var colliderObject : GameObject;

if (colliderObject.Collider.OnCollisionStay) {
//do my code

I define the GameObject in Unity, but it says something is undefined. help is appreciated.

I would also like to point out that the GameObject is actually a bunch of boxes that are parented by another box.

That’s wrong: OnCollision events are called by Unity, not by us. And in this case you should use OnTrigger events instead:

1- Set this box Collider/IsTrigger field in the Inspector: this transforms the collider in a trigger: it will not block the player, but events OnTrigger will be generated when the player enters/stays/exits the trigger.

2- Put the OnTrigger code in the player’s script:

// insideArea is true when player inside the trigger, and false when it's outside

var insideArea: boolean = false; 

function OnTriggerEnter(other: Collider){
  insideArea = true;

function OnTriggerExit(other: Collider){
  insideArea = false;