How use For each loop and timeline ?

timeline is asyncronic…its like a delay…it has its own time. each time you reach PLAY it just runs the timeline (if stoped starts playing, if playing does nothing).

For loop runs the whole loop (x to y) and stops everything until it finished before continue the flow of the game. Its not async. thats why you can use For loops in functions but cant use timelines…note timeline node has a clock on it. that means async (like events)

You must create those components and put all in an array, then PLAY FROM START and in UPDATE from timeline put another for loop that iterates all the components (take the array and make a FOR EACH LOOP) and update the scale there.

Also you have a flip flop…so you create the static meshes and then you play in reverse…then you create AGAIN and reverse CREATE reverse…you are adding static meshes on each FLIP and dont getting rid of it on the FLOPS…here is some that can work deleting the static meshes when reverse ends:

anyway maybe is better to create that array of static meshes at the beginning of the game and keep them hidden…then instead of create/destroy you just unhide, use and then hide again.

Create/destroy stuff is the less efficient stuff :slight_smile:

5 Likes