Right so I’ve been trying to figure out how to do this for a while now and I’m getting pretty confused and frustrated.

In the picture I have a cube which has a player controller script attached. The box colliders surrounding it are child empty game objects to the cube. Each one has it’s own script to detect whether it is touching a box collider within the white cube. The white cross is made up of individual cubes each with its own box collider attached. What the player colliders are trying to do is detect whether it is touching a box collider of the floor, if it is then it lets the player move. However the way I have done it might have been a bit wrong. Here is the script attached to the box collider at the front lower side of the cube:
using UnityEngine;
using System.Collections;
public class ColliderFB : MonoBehaviour {
void OnTriggerEnter(Collider bcFloor)
{
CubeController.fwd = 1;
}
}
This box collider attached to the floor gameobject is bcFloor and it detects it fine however once it detects it then CubeController.fwd is always set to 1 which means even if the two box colliders aren’t colliding anymore then it is still = 1 which is not what I need. Is there a way to detect if the two box colliders are no longer touching? I’ve tried OnTriggerExit but this just causes the player cube to not move. Here is how I instigate it into my PlayerController script.
public static float fwd;
public static float fwd2;
void Update ()
{
if (Input.GetButtonDown ("VerticalFwd"))
{
MoveForward();
}
}
void MoveForward ()
{
if (fwd == 1 fwd2 == 0) {
amountToMove.y = 1f;
transform.Translate (amountToMove);
} else {
}
}
fwd2 is the box collider detecting any colliders directly infront of the player. fwd is detecting them infront -1.
So if there is a collision in the BoxCollider script then fwd = 1 in the PlayerController script and the player can only move if fwd = 1. What I’ve been trying to do is check if in the BoxCollider script the collision is no longer happening, therefore fwd = 0 not allowing the player to move in that direction any longer until there is a collision between the two collider again, ie. the player moves back causing the colliders to collide again. Any pointers would be helpful, if I’m going about all this completely incorrectly then let me know. I’m using all the box colliders because I’m not a very logical person and it seemed like the most logical way to achieve what I have in mind.
