Collision Problem - Floor Button & Character Controller

Hey guys,

I’m currently developing puzzle game, where the floor has trap buttons. I have tried most of the collision methods to detect when the player object (character controller) is over the trap button. The trap button is a cube and it cannot detect when the player is over, does anyone know how to fix this or have an alternative solution?

Note:
(1). The cube does have collider.
(2). The character controller does detect the cube, but I want the cube to detect the player.

Thanks for the help guys, appreciate it!

So, you want to make a empty game object with a collider that is going to be a trigger by clicking “Is Trigger” and then add a script with this code:

var PlayerIsOn = false;

function Update () {

if(PlayerIsOn == true){

//Your Code here
}

}

function OnTriggerEnter (Other : Collider) {

if(Other.gameObject.tag == "Player"){

PlayerIsOn = true;

}

}



function OnTriggerExit (Other : Collider) {

if(Other.gameObject.tag == "Player"){

PlayerIsOn = false;

}

}

NOTE: TAG YOUR PLAYER TO “Player” OR ELSE IT WON’T WORK.

NOTE: YOU MUST ATTACH THIS EMPTY GAME OBJECT TO YOUR BUTTON GAME OBJECT.