Digging system like Dungeons 4

Good morning, My wife has been playing the game dungeons 4 lately and I like the system where the peons dig…

was thinking of trying to come up with a system like this (If you are not familiar with this game look https://www.youtube.com/watch?v=T3XmIm46q4M – you can see him marking blocks to mine right at the beginning)

Walking through how to make this in my head - I would have a blockActor that holds things like hit points of the block, and maybe have a tag if its stone, gold, etc… my “Player” controller would just mark the blocks I click (Figured I would break the hit out and get the tag, etc)

What I have not figured out is how the little NPC’s AI I could tell them to go to that “block”… Can I add a block to a blackboard? I could have the behavior tree check to see if there is any valid target if so mine it, if not just idle… Going to start trying it out this evening after work was just curious if my approach is how you more seasoned developers would do it?

Depending on how many blocks are needed, using fully fledged actors for this may turn up to be performing poorly in the long run - but actors are flexible, ofc. Instead of actors, you could use an extended Static Mesh component and have it own the data / methods. Or take it even further:

  • consider the Instanced Static Mesh component - you could render 100k blocks without dropping a single frame (slight exaggeration for dramatic effect). Avoid the hierarchical variant, at least for now.
  • associate blockID (Hit Item) with a struct data in a map variable
  • never destroy blocks as this would wreck havoc with ID ordering. Instead, move the “destroyed” block where the player can no longer interact with it (under the map?), update its data to reflect it.
  • look into how Custom Primitive Data works - it could dramatically simplify handling of the block materials; as a bonus it would offer another significant performance boost.
  • get familiar with dynamic navmesh
  • depending on how complex the AI tasks become, going full BT may be a must. If you already have a firm grasp on it, do not hesitate. However, for simple prototyping, it might be an overkill.

Thank you, lots of new stuff I have never used so may be a good idea to try it out! Thank you!

Off to google I go. :slight_smile:

Have a look:

That could be the gist of handling blocks.