Enabling functionality based on location ... Raycast ?

Hi, imagine a square game area, divided into 4 areas. Each area is tagged One, Two, Three & Four. I want to be able to detect which area my First Player Controller is over so that I can enable and disable certain functionality.

From the research I have done, Raycast, looking for a collision and then examining the Tags of the object that collided with seems to be the way to go, and I have so far created this code, which creates Debug output to prove it is working before I start adding the actual functionality I need.

void Update () {
	RaycastHit hit;

	Debug.Log ("(1) In menu controls update");
	if (Physics.Raycast (transform.position, -Vector3.up, out hit)) 
	{
		float distanceToGround = hit.distance;
		Debug.Log ("(2) distance to ground is" + distanceToGround);

		if(hit.collider.CompareTag("Two"))
		{ Debug.Log ("(3) Were over Two");  }
		else
		{ Debug.Log ("(4) Were not over Two"); }

	} else 
	{ Debug.Log ("(5) dropped to else"); }
}

So this runs, and when moving around, I see Debug Lines 1, 2 with two demonstrating an appropriate distance to the ground, and then I see Debug Line 4, I never see lines 3 even when moving into Area Two or Debug Line 5 ever, which is fine.

The Tag is correctly set to Two, the Assets that are Tagged have a Mesh Collider on them.

Can anyone see what I am doing wrong, or can you suggest a more appropriate way of achieving something like this ?

Cheers

Craig

FIXED

The code was correct, I have continued to change elements on the periphery to try and narrow down where I was having the problem.

My “area’s” were for the sake of order, contained in 0,0,0 referenced empty GameObjects, and it was to these that I had added the Mesh Collider and the Tags. This wasnt however my mistake, I had assumed that the settings cascaded down to the contained objects but they didnt.

Now I have set the actual objects involved to have Mesh Colliders and Tags, all is working perfectly.