Spawn actors using Timer

So, I’ve taken the Random Foliage BP from the Blueprint Office examples, and I added some things into the event graph to increase the radius and number of meshes to spawn every few seconds. The problem is, it seems that what I’ve done has no effect. I tried the same thing in the construction script, but that doesn’t seem to help.

Construction Script executes only once when it is created. When you change the radius in runtime it doesnt matter because construction script already finished the event when you placed it in the level. So you may want to translate that const. script network to event graph if you want run time interaction like that.

Ah, that’s what I was hoping NOT to happen… alright. So now the trick is to separate what I can without breaking it…

Okay, so I managed to almost get it working. BUT The timer still does not execute the script. It executes once upon “begin play” but does nothing afterwards. Is there an alternative (or actually correct) method to execute a script every so many seconds? All I did was connect the above nodes between “event begin play” and the existing random foliage Blueprint.

This is a snapshot of it in runtime. It populates the boundary, but it never updates.

You need to create a Custom Event and plug it to Set node. Then put the name of your custom event into the timer’s function name and it should work.

i think you mean function ;p

Put the name of function in “Set Timer”, you don’t need to do anything with events. But there other node that let you bind timer to event if you want.

Which set node? Perhaps if you could point me towards an example? I’ve never had to use functions/custom events yet, still learning. So far this is what I have

Instead of executing all functions at once like the first giant forest box, it used the default settings I set, but made no changes at runtime. The timer is executed by Event Begin Play still, but the timer’s function name is set to the Growth Timer Custom Event.

But is the Function supposed to contain the nodes in that last pic?

Currently my setup is exactly that as a function, and this attached to the working Random Foliage BP. It shows that the size and number of meshes should update every 5 seconds, but that isn’t happening. It populates the area once and then never does it again after runtime.

Okay, new problem. When I did as you said, it spawned once as usual. So I added a “Print String” to both the function and the event graph. At the beginning, all strings print. Then only the function’s prints every 5 seconds. I am very confused, as much of this is new to me still…

As far as I know, all scripts are firing when they’re supposed to, but “Print string” and the innitial spawn are the only things working. The radius does not increase at all, or perhaps it does and it just isn’t spawning additional instances

Perhaps I should explain: My original thought was to spawn a small forest, then periodically multiply the radius and number of meshes to spawn, then run the spawn event again with the updated variables. But that doesn’t seem to be working…

Plug “Self” to Object pin, you need to define object where function will be called, in this case it will be object where “Set Timer” is so plug “Self” node or check if you don’t have self option in “Select Asset”

Because you not using Radius in calculations so Power result will be the same

I actually changed that while nobody was looking, still the same results. No increase in radius and no new spawning…

I can get the growth timer to act as a trigger, that much is certain.

Finally got it to work… I found that my radius was increasing so exponentially that foliage was spawning much farther than expected. With some more tweaks I can get it working in an environmentally friendly manner.

What I did: I created two custom events. One that triggers the new scaling, which fires after spawning, then another that fires once the new scale is resolved, which re-triggers the spawn cycle. Thank you, and for helping me realize the problem :slight_smile:

NOW another problem has arisen, after about a minute, the engine realizes the BP is going to continue spawning trees until the end of time, and says, “Infinite loop detected”

Immediately after spawning.

about half a minute later

and then I get the error message and it kicks me out of Simulation