Hi everyone.
In my project I try to destroy bricks (Instances) after a certain number of hits. For now I’m able to destroy each whats a clever way to add points of health to an instance?
If you have any question on what i have set up rn i will be glad to answer.
Sorry for weird english also :}
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 takes their neighbours with it (I’m thinking you’re making an Arkanoid but you might be about to Minecraft 2.0)
we need to feed the material a 0-1 Alpha range for the Lerp so we math it out
if you’re creating thousands+ of those, it might be worth looking into how Dirty State works
a Custom Event pipes in an index of the hit instance
we find its data in the Map and adjust it, removing 1 hit from Remaining, and shoving the value back into the Map
we update the material in a very similar fashion as before
we need to get rid of an Instance if no more Hits remain…
…if you were to remove an instance of an Instanced Static Mesh, the indexes would get jumbled and we’d need to rebuild the Map; so we don’t remove the Instance, we move it below ground instead (or where the player cannot interact with / see it). This way the indices remain intact.
Do tell how it goes. Technically you don’t need Custom Primitive Data for this and simply keep it all in a map only. But you did ask for clever and it’s not a bad use case scenario for the feature.