I’ve got a cube with a player controller script attached, then I have multiple collision boxes with the cube as the parent object at points around the cube. My enviroment is also made up of cubes each with a collision box attached. What I am trying to do is see which of the collision boxes attached to my player has hit one of the other collision boxes outside of my player. Ie. the cube has 4 collision boxes, one on each 4 sides of the cube, if the front collision box has hit a collision box of another game object then do function. This is what I have so far. bcBottom is attached to the cube whilst floorBc is attached to the outside gameobject I am trying to create a collision between. If it has hit it then fwdMove = true, if not then it’s false however it is never coming back as true only ever false.
void OnColliderEnter(Collider bcBottom) {
if (bcBottom.gameObject.tag == "floorBc") {
fwdMove = true;
}
}
void Update () {
if (Input.GetButtonDown ("VerticalFwd")) {
if(fwdMove == true){
amountToMove.y = 1f;
transform.Translate (amountToMove);
} else {
fwdMove = false;
}
}
}