Moving items in a Loop

I’m trying to create a mechanic where i have a staircase that’s flat, and once an event is triggered the staircase will rise

Right now i just have a construction script with a forloop that lets me create a modular staircase

the issue is trying to move the steps with an event. The only way i’ve found it to look like what i want is by replacing the steps, although it adds steps every frame then. I’ve tried just setting the worldlocation, although it doesn’t move the steps then. i’m not sure if there’s a way to move static meshes created by a forloop

263991-test.gif

(sorry for the poor gif quality, i had to optimize it heavily just to upload it)

and thank you for any help

you certainly could.

but would also like to point out that if you 3d model the stair, you could change it’s Z scale from 0.01 to 1 and the visual effect would be the same. The bottom part of the stair would be a separate cube mesh though.

do you absolutely need to do it proceduraly?

Evigmae is right that using a complete staircase mesh, and updating (animating) the Z-scale, would be much simpler in terms of blueprint scripting.

But maybe you need staircases that span longer and shorter distances, and staircases therefore need to be adjustable in the editor. Or maybe there’s some other reason why you definitely need to procedurally create and animate the individual stairs.

If that’s actually the case, you’re going to want to start by thinking about your “spawning” and “animating” actions as completely separate. As you already pointed out, you definitely don’t want to be spawning in multiple stair meshes every frame.

So, basically, create the stair meshes just like you already showed in your first image — this is the “spawning” step taken care of. But you should then also keep track of these stair mesh components (store them) in an array variable in your staircase blueprint for easy access later.

Then, when the staircase is triggered to rise (which can be done multiple ways, and is entirely up to you), an event is executed on the staircase blueprint (which you will also need to set up) that causes each individual stair component in the array to begin moving.

You should still be able to use the Timeline node you have to make the movement work; just toss a ForEach loop after the Update pin, and multiply the Timeline’s output by the index of the item in the loop.

Or, if you’re curious about another way to animate the stairs, take a look at the VInterpTo node. It might not work better in this case, but it’s a useful thing to know about.

There are a few details I left out, but hopefully this makes enough sense that you can put it all together and get it working.

Best of luck!

Thanks! Right now i’m using the z-scaling method as a temporary fix, although i would like to try the other method later, i’ll update if i can figure it out. Thanks for the help!

Thanks! and yea, i would like it to be procedural, although this works too! I can still choose the stepcound and height