Simple Hexagon-map strategy game

Hey Guys,

I’m an experienced programmer and modeler but I am just now jumping into unity. I know how to script and can understand C# and javascript, but am using javascript for my game.

I’m trying to make a simple game prototype for a simple turn based strategy game. I have a grid of hex objects and 99 percent of the UI will be clicking on the hex tiles and moving units and attacking other players hex tiles.

I’m not looking for a step by step how to do this, but I kind of a need a pointer in the right direction to get me started. So far all I have is a 6x6 grid of hex tiles. And I would like to start scripting. A few things that I’m confused about:

Best way to manage/reference my tiles (One mesh with lots of faces? or seperate game object for each tile?)
How do I locate which tile the user clicked?
How do I implement a turn system? (player 1 > end turn > player 2 > end turn > …)
Like I said, you don’t have to be specific. A general overview on how people usually do this kind of game is fine and I can figure out the rest.

(Wasn’t sure what topic to post this question in, so it put it in scripting, since i’m mostly concerned with the scripting side of this project)
Thanks! -Gabe

i would do each tile as a seperate game object. Then you can build maps based on tiles and put them together yourself or even dynamically change them without too much trouble. Stick a collider on them and study the hell out of the Monobehaviour class http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.html. It has an OnMouseDown function you can write for a tile script that picks up when its selected. then you can send a message to a GameStateController script on what object was clicked.

Good luck to you and welcome to the forums.

Are these 3d tiles or 2d tiles? It’s not clear from your question. I’m currently making a 3d game on a hexagonal grid from scratch but all I can advise you to do is find some pre-made hex-map system on the Asset store if you can afford it.

Ok, I can advise you a little more than that:
-one simple hexagonal mesh collider per tile for the raycast click detection.
-a different Tag for each terrain type (…if (hit.collider.tag == ''Bog")…)
-a visible model object, which is a child object to each tile, that a master setup script sets to one of many prefabs based on terrain type and the surrounding six tiles.

  • as far as implementing the turn system, first read up on multiplayer. Then it’s just as easy as “var myTurn : System.Boolean.”. But the multiplayer stuff is not trivial.
  1. I recommend you look into ray casting,

Something like this:

private Ray ray;
private RaycastHit hit;
if(Input.GetMouseButtonDown(0)) {
	ray = Camera.main.ScreenPointToRay(Input.mousePosition);
	if(Physics.Raycast(ray, out hit, 100)) {
		if(hit.transform.tag == "Tile") {
			//Set this to your new tile you want to move to etc... 
		}
	}
}
    • I would store a variable, a integer maybe. Then just keep setting it to 1 or 2 when the player is done, then only let the player do something if the integer is = 1 or something like that. hope you get the jist.

Strangely enough, I posted a similar question in the Unity GUI forum since I was thinking using that system for creating a 2D hex map editor. It will be interesting to note the differences between the two approaches.

TAZ