# Digging system like Dungeons 4

**URL:** <https://forums.unrealengine.com/t/digging-system-like-dungeons-4/1849794>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [May 10, 2024, 3:02pm UTC](https://forums.unrealengine.com/t/digging-system-like-dungeons-4/1849794 "2024-05-10T15:02:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BigDadBoom243](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BigDadBoom243](https://forums.unrealengine.com/u/BigDadBoom243)\
**Post date:** [May 10, 2024, 3:02pm UTC](https://forums.unrealengine.com/t/digging-system-like-dungeons-4/1849794/1 "2024-05-10T15:02:11Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 10, 2024, 4:03pm UTC](https://forums.unrealengine.com/t/digging-system-like-dungeons-4/1849794/2 "2024-05-10T16:03:15Z")

</div>

> [@BigDadBoom243](#):
>
> I would have a blockActor that holds things like hit points of the block

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.

---

<div class="post-metadata">

**Author:** ![BigDadBoom243](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BigDadBoom243](https://forums.unrealengine.com/u/BigDadBoom243)\
**Post date:** [May 10, 2024, 4:16pm UTC](https://forums.unrealengine.com/t/digging-system-like-dungeons-4/1849794/3 "2024-05-10T16:16:06Z")

</div>

> [@Everynone](#):
>
> > [@BigDadBoom243](#):
> >
> > I would have a blockActor that holds things like hit points of the block
> 
> 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. 🙂

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 10, 2024, 4:18pm UTC](https://forums.unrealengine.com/t/digging-system-like-dungeons-4/1849794/4 "2024-05-10T16:18:10Z")

</div>

Have a look:

> [@How to add a hit count (health points) to individual instances?](https://forums.unrealengine.com/t/how-to-add-a-hit-count-health-points-to-individual-instances/227176/2):
>
> The name of the game is Custom Primitive Data (check docs at the bottom). The material for a brick: each instance stores a float which is used to Lerp between 2 colours (to visualise hits remaining) this can (and probably should) get prettified Making a brick wall: create a bunch of instances and store their data in an int | int Map instead of an integer, you could have a struct and hold all kind of data here; perhaps this brick is worth some coins, or explodes when destroyed and …

That could be the gist of handling blocks.
