Download

How to have an asset reproduce itself?

Hi, I’m new to game development and in need of some help. I would like to have an asset (like grass) reproduce itself over time. Object needs to wait 5 minutes and then reproduce itself and place the duplicate a short distance away for itself. It should cover the entire map over a long period of time. So it should be kind of like Minecraft when you make the cows have babies but in my case the reproduction will happen automatically.

Ok, so this is pretty easy. You can go about this two ways depending on what you want:

Begin play, wait 300 seconds, spawn actor from class, actor being the mob.

if you want to have each AI to continue multiplying after the first time, I don’t know how to do this, but do everything before but in a loop. The problem is Unreal doesn’t like delays in a loop, and just skips them. There HAS Be a way to solve it, but I don’t know that way.

You can use “SetTimerByEvent” in Blueprint with which you can trigger events after a specific time.
This can also be looped and you can also get a handler to the suiting timer.
This handler can be pause, started again, cleared or checked etc.

Is the problem the “wait a while” or is the problem “how to spawn a copy of myself?”

For the “spawn a copy of myself,” you can get the class of your actor, and the transform of your actor, and then break / add offset to the position, and then plug all of that data back into the Spawn Actor of Class node, to create a new copy.

Also note, if the original grass keeps spawning every N minutes, you will have exponential growth, because both the old and new grass will spawn another grass after N minutes, then all four will spawn after N minutes, … This is the “grains of rice on a chess board” conundrum. Also, if you spawn more than once, make sure the second spawn goes to another position than the first spawn, so they don’t end up just z-fighting in the same place.