foreach (HexScript hex in SelectionManager.allHexes)
{
if (hex == terrainOn)
{
print(name);
hex.unitsOnHex.Add(transform);
}
}
–
I am making a turn-based strategy sort of game.
The code above is in Start() of every unit in the game. The board is made up of hexes, each with HexScript attached, and all are stored in the list SelectionManager.allHexes. Each one has a List of all the units on it. terrainOn stores the hex that the unit is currently on.
The problem is that for about half the units, this works fine, but for the rest, hex is never equal to terrainOn. Even within the exact same terrain type some work and some dont.
I have checked that terrainOn is storing the correct hex, and it is, and all of the hexes are in SelectionManager.allHexes, so I have no idea what is causing this.