Ten minute game jam!

Thanks. I actually have implemented something like that. I have a singleton grid manager that handles neighbors, A-star pathfinding, coordinate conversion, and other big-picture map stuff. My hex class is in the low-level ‘front lines’ - it handles all click events and decides whether a click is selecting a hex or unit, or initiating an attack, etc. It works well enough, but I wonder whether I should’ve put all that stuff in the grid manager. I’m just going to plow on because it’s working fine so far, but I’m interested in learning more about game architecture for my next project.

So am I! :)

This all sounds very sensible to me. Having Gameobjects in the thousands (as long as they have no Update or similar callbacks) should be fine, and allowing each hex to manage clicks and other interface stuff avoids a lot of busywork.

As to working in UI… as others have said: do what motivates you. I do however think UX (which in a game like yours does include UI) is something that needs to be built up gradually as the project develops. If you try to do all the UI at the beginning, it will suck and need to be redone, but if you don’t work on it until the w end, it will change your game and force you to redo a lot of other stuff.

Is anyone here knowledgeable on the Unity Search queries/expressions (ctrl-k)?

All I’m trying to do is find all mats in the project that use a specific shader, and for the life of me I cannot get it to work!

Wish I could help, @Profanicus. I didn’t even know about ctl-K until you posted. I just played around with it a bit and looked at the manual. I assume you’ve tried typing ? in the search box to see different ways to limit the search. I tried searching for materials and shaders in my project, and I could find them separately, but I couldn’t find a way to filter materials by shaders. A google search suggests there are code-based ways to do this, maybe by modifying the editor, but that’s all beyond me.

I’m using only two shaders so far, one for my line renderer, one for everything else. I am thinking of using one to make “in-range” hexes brighter. I imagine that’s a common use case for shaders?

Also, I’m finding the first and last X’s the easiest to design in a 4X. The middle X’s (exploit/expand) present so many tough questions. How many resources? (I want a lot, but if I ever want to finish this, probably should settle for fewer.) Production chains or not? (I’d like them, as in Imperialism 2 or a city-builder, but the worry is they become tedious.) On-map builders that take time to construct stuff, or just directly build with a mouse-click, as in a city-builder? Cities with city-radius, as in Civ, or fewer cities with more logistical constraints, as in Shadow Empire? (I am trying for the latter.) For most of these decisions, my answer is usually “make the game I want to play,” since I’m not doing this to get rich or anything. But wow, a huge challenge. Game design is hard!

Yeah I use the search every day and know how it works for simpler stuff, just not so much about the in-depth query language thing they have. There are examples in the docs kind of showing how to do what I wanted but nothing I tried worked, in fact some keywords I tried didn’t even seem supported. :P

Depends on the approach, lots of small dedicated shaders or a couple bigger ‘uber’ ones?

We’re using the more ‘uber’ method atm, but even the basic Unity shaders should allow something to go overbright into HDR range by setting the colour on the material past white.

Thanks for your reply. I’ll try tinkering with the white setting on some basic Unity shaders. I don’t need anything fancy, at least not yet!

Sorry I can’t help on your query query. Now that I know about it, I have started using it too. It can be very useful, but yeah, I don’t fully understand it.

For now, back to the economy balancing. Gah! It’s so hard.

It has some very neat stuff, like the ‘i’ icon at top right turns on the built-in inspector. The 3 view-mode icons at bottom-right allow you got to into a ‘table’ mode, where you can add columns and edit multiple object values like a spreadsheet. And magnifying glass at top-left to save queries, to bring the same objects back up later for further editing.

Still a bit buggy but some good stuff in there.

So my project (a military-themed 4X) is moving along nicely. I haven’t had a “how do I do this in Unity” question for quite some time now. I still find and fix bugs every day, but they arise from my own pretzel logic. I feel like I’m getting better – and faster. I look at my older code now and I cringe.

Game design is hard, though! The wargame side of my game comes naturally to me, as I’ve been playing hex-based wargames since I was a kid. But the economic side is more of a struggle, even though I’ve been playing Civ etc since Civ 1. I do want to make a traditional historical wargame, but my thinking was to start with these 4X prototypes and projects to learn the basics of hex-based mechanics and especially AI. Heh, maybe I should’ve started with a wargame instead.

But for now, I’m having great fun with this. I’ve finished a first pass on movement by both the player and AI, combat by both sides, economic development by the player., fog of war/exploration, and enough UI to allow me to test. Now I’m working on a couple alternative scripts for marauders to attack the player’s starting village early on, as well as defensive scripts for enemy units. AI for a game like this is much harder than it was for chess, and it was very challenging for chess.

I’ll post a few screenshots in due course. :).

I look forward to the time when beta-testing begins!

How are you handling the AI architecture?

Excellent question! Until now, my main experience has been a utility-based system, either coupled with the min/max algorithm (chess) or map position (a small wargame I did for a game jam). That is, the AI evaluates the utility (value) of the board state, then compares that value with the outcome of various possible moves, which can be generated by a breadth-first search, maybe coupled with the A-star search algorithm. Ultimately I hope to use such a system here too, but this map is much larger, and utility very much harder to measure. I’m sure I can’t do eight-turn-deep min-max searches on a huge hex grid, lol.

So to get started, I opted to experiment with a menu of possible scripts. E.g., an early-game rush against the player, or a turtle, or marauders taking on anyone on the map. It helps that my design relies on asymmetry: the player is ultimately struggling against a far more powerful foe, as in AI War.

I’m also interested in exploring simple emergent AI, like the card-based system in the solitare module for the hex-based board wargame “Conflict of Heroes”. In that system, each object gets its own simple behavior tree, and that produces surprisingly interesting results. I’m going to be busting out that game’s cards shortly to see if I can glean anything from them.

I am keenly aware that I’m a newb at this, so I’m very open to any suggestions – especially reading on the subject. I’ve looked at a few articles online, but I’m not really sure what the must-read sources are. This article has been helpful, and I’ve read a lot about min/max, but I’m not sure where else to turn.

Nice! I was looking at some Utility AI videos on Youtube yesterday. Interesting, but beyond my current learning on the topic - you say you’re a newb but I’m even lower level, having never really done any AI at all before. :)

So since I have no idea what I’m doing, I of course put my hand up to do some in our current project! It has a rudimentary FSM system in place that I’m using, and I’m already hitting some issues with the way that’s been architected. It’s easy enough to set up all these different behaviour states, but not so easy to do variants on them without also doing variants of every dependant state.

I need to go back to the old ‘pluggable AI with scriptable objects’ stuff for ideas on that I think, though most learning material around this kind of thing seems to be ‘one script handles entire AI behaviour’, which is too simple for my/our needs.

I’m familiar with the card-based systems used in board games like CoH, very cool approach to see how it translates to a video game. The next step from that would be the bigger flowchart-based AIs in some of the COIN games, where each faction has their own charts.

Oh, that’s cool that you’re familiar with CoH. It’s a great little solitaire AI system. I didn’t really get into the game until I bought that solo expansion.

Heh, I doubt you’re any more newbish than me. I haven’t really done anything with FSMs. My games usually have gamestates, but that’s not the same as AI that uses a FSM. I may try using FSMs for this AI too.

Also, I tried to implement stuff with scriptable objects in my current project, but I didn’t quite grok them and gave up. May try again.

On a different note: I’m liking the new input system. I’ve got a lot of user input in my game now, and I animate enemy units as they move across the board, but I still have not used a single Update() call. The moving units do their thing inside a coroutine. Everything else is handled by my input modules. I find it very satisfying. The learing curve was a bit steep, though, and I certainly woudn’t switch to it mid-project.

@Spock could you give some pointers on how you implemented the hex grid? Are you using the grid component or its ask home brew?

@marxell My hex grid is home-brew. I messed around with the built-in hex grid and built-in hex tiles, but I read posts by the dev of “Hex of Steel,” a WW2 wargame. He said he had better peformance just making each hex its own object, even with thousands of hexes. So I did the same. I have a hex class and a simple hex prefab based on a sprite I made in Photoshop, and I generate the grid at runtime. Each hex detects when it’s clicked on; stores info on its terrain and occupants; and my hex script does much of my input handling.

It’s a bit tricky to set up the grid, but I’ve done hexes once before, and I found it surprisingly straightforward in Unity. I essentially follow Amit’s often-linked guide to hexes and hex grids here: [Hexagonal Grids](https://Amit’s hexagon page) As he says, you can represent hexes with “offset coordinates” (like a square grid, with a dictionary or array), or you can use “axial” or “cube” coordinates – harder to grasp, but easier to use for algorithms. (These coordinate systems essentially imagine the hex grid as a big unfolded cube.) It’s best to read his site, as he explains it better than I can.

I use pointy-top hexes. I use axial coordinates for my big algorithms (A-star search, breadth search, neighbors, etc); and I use offset coordinates (simple x, y) to store the grid. It’s not as complicated as it sounds, but it does take getting used to. Amit advises us to use axial coordinates for algorithms, but sometimes I wonder if it would be simpler just to use offset coordinates for everything. It’s a constant nuisance to switch between the two coordinate systems. Needless to say, I have dedicated conversion methods, basically plucked from Amit’s site.

I do think the built-in Unitiy hex grid and hex tile could work well for 2D games. So don’t let me discourage you. For my project, a custom solution seemed like a better option. I hope this helps.

Thanks, I’ve been uncertain about the best way to go. I usually find that is easier for me to do things by myself as is easier for me to understand. Knowing that’s it’s viable helps. Thanks for this links as well.

I agree, I learn better by figuring things out for myself. Amit’s site is truly awesome – I hope you find time to check it out!

Are your hexes 2D?

In a 3D world?

Oh, my game is purely 2D. For a 3D solution, I’d highly recommend the amazing series of tutorials by Catlike Coding. I worked through half of them before I started this project, even though I was pretty sure I’d be going 2D, because they’re enjoyable and educational, and some of them teach lessons for 2D development. They’re also in writing, extensively documented, and mostly quite easy to follow. Check them out here!

He’s also published a more up-to-date Hex map project that uses the universal render pipeline (URP). I haven’t looked at it. My advice would be to start with the tutorial I linked above; it has a link to the newer Hex map project.