I’m trying to create a custom ‘ForEachLoopWithDelay’ that accepts a delay put as a Float.
However, if the Float is set to ‘0’ then I’d like for the current loop pass to wait for the current Tick to finish and a new one to begin on the next tick, allowing me to spread Loops over frames.
Does anyone know which Node I should be calling in order to do this, or if I can create one like this?
To what end? I ask because loops are SUPPOSED to iterate entirely within a frame. Doing an action repeatedly across a specified duration of time is better handled by timelines or timers.
If you need to do something for each value in an array sequentially from tick to tick, it might be better to set an Int variable to 0 whenever you (re)set your areay… And then fire a timeline or timer where you want your forEach to be, and have each pulse perform the desired operation on the array entry at Index Number [Int variable], then increment [Int variable] by one (using Get Int, Int + Int and Set Int in sequence).
So every tick (or loop of the timer or whatever), it performs the operation on one element of the array, and then queues up the next element to be processed on the next tick.
Loops are supposed to work like that, but there is nothing wrong with creating custom Loops that spread the work out.I’m doing this for Performance reasons. I’ve got alot of AI characters doing alot of checks similtaneously, but I don’t need the results instantaneously and can afford to spread them out over frames.
I’ve already got an incremental delay system in & I don’t see how your system would be any different to how I’m doing things now. However I would prefer to spread them out over whole frames, which can vary in length, than a set time period which, which could miss frames.
Plan B is to use an ‘Event: Update Tick’ to open a gate within my cust Loop With Delay, but I would prefer it if there was a ‘Wait For Current Tick To End’ / ‘Wait For New Tick To Begin’ Node in BP.
[EDIT] I’ve tried creating something similar in BPs myself but it doesn’t seem possible to add a Tick Event into a Macro. I’m also trying to reduce the load I’m putting on Blueprints to do work so a Coded node would be better than custom one created within BPs.
Thanks , I’ve put a request in for a ‘Wait For New Tick’ Node in the ‘Feedback For Epic’ forum.
If you can think of anything else you’d benefit from regarding Tick checks then do you want to add it in there? That’d probably help get momentum behind the requests
Since you made the new post in the feedback forums, I am going to close this one so we can focus the conversation in one convenient location. Please continue in the feedback thread. Thank you!