I’m working on a HoMM3 clone. I’ve got a hex map in form of a 2D array
GameObject[,] hex = new GameObject[11,15] - 11 rows, 15 columns. Each hex has a script called Data attached to it which holds all it’s variables such as:
int y - row number
int x - column numer
bool obstacle - true if there is a terrain obstacle on that field
bool unit - true if any other unit stands on that field
bool canMove - true if active unit can move on that field
Each unit has a variable
int speed which is unit’s movement speed in hexes. The problem is that units should not walk through other units and/or terrain obstacles, therefore they need to take longer paths. Pic related
Bear with the yellow highlight is the active monster, it has speed of 6 (as seen on his left side), but due to obstacles and units in north-east direction, he can’t go everywhere where he normally could, as he must take the longer route.
I need this script to change
canMove variable of each Hex to true if active unit can move there.
The map is made of 3D gameobjects seen from above with Orthographic camera.
Each unit is an empty GameObject with it’s transform.position equal to transform.position of some Hex. It has a Plane child with the unit graphic.
I’m a C# man