Monday, 2 December 2013

Numpad Forever

New build. After some difficulty and dragging ass I finally got a pretty good version of the keypad movement up and running in Unity.  I know when I play Civilization I favour the keyboard whenever I'm moving units around.  Moving units around is going to be what you spend much of your time doing in the game so I'm working on these lower level systems then building up from it.

Check out the build,  (Instruction on that page but mostly tap the numpad keys)

The rare ideal case - all 8 directions mapped.

Debug build in xna.  The fuzzy values in the top left
map how each node best fits each compass direction.

I'm still finding it much easier to tackle issues in XNA then move to Unity.  In the bottom image I have all the fuzzy logic values printed on screen.  In that particular image, I have to shuffle the mappings a little on the North East to the South as they don't fit neatly, seeing the problem and values all on screen was very helpful in tackling the problem.  The heuristics are broadly:

  1. what directions can these nodes fit?  (calculate fuzzy values for all 8 directions)
  2. where is the best/ideal fit?  (pick the best fuzzy value)
  3. are any nodes not mapped, if so try and slot in.  (use a less than perfect fuzzy value to find a spot) 
  4. failed to neatly plot so plan B.  (use a secondary plotting and allow the player to toggle between)

I'm starting to appreciate why turn based strategy game mostly adhere to nice uniform grids.  Though I've got it largely working quite well there are still a couple of edge cases.  Couple of stupid moment these last couple of weeks.  The directions where half broken at one point until I realized XNA uses a right handed coordinate system and Unity is left handed.  Second one was spending over an hour wondering why icons weren't changing/appearing/vanishing and getting null console messages when I was clearing adding the game object to the script! Then I realized I was adding them in the wrong place...doh.  That's going to be a recurring theme, I'm still a little clumsy using Unity.

Updated to Unity 4.3 with no issues. /hurray