I am trying to create a hex grid map where the player can hit x to explore the current hex and the boolean for that hex changes to true. I have had no luck referencing individual instances from the character controller script, so now and trying my luck at the explore function of the hex script on my instanced prefab on the hex grid.
However, when I press x at runtime, all the hexes with the script update, rather than the one that the character controller is currently colliding with.
I have a feeling I am doing something stupid here and would appreciate some direction.
Code:
void Update ()
{
if (Input.GetButtonDown (“Explore”))
{
ExploreHex ();
}
}
private void ExploreHex()
{
//Determine time passed from exploring
if (Explored ==false)
{
//timePassed = timePassed + 24;
//Calculate time passed and period of day
//daysPassed = (timePassed / 24);
//hoursPassed = timePassed - (daysPassed * 24);
//whatPeriodofDay ();
//Set hex to Explored
Explored = true;
Debug.Log ("You explore the Hex");
}
else
{
Debug.Log ("The Hex has already been Explored");
}
}
Also, Explored is initialized here:
public bool Explored;