Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

alt text

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

alt text

alt text

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

and thank you for any help

Product Version: UE 4.20
event-graph.png (284.7 kB)
test.gif (3.8 MB)
more ▼

asked Jan 03 '19 at 02:08 PM in Blueprint Scripting

avatar image

58 4 7 15

avatar image Evigmae Jan 03 '19 at 02:45 PM

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?

avatar image kaosrio Jan 03 '19 at 10:23 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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!

more ▼

answered Jan 03 '19 at 05:10 PM

avatar image

1.2k 4 5 8

avatar image kaosrio Jan 03 '19 at 10:22 PM

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!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question