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"

Play timeline inside ForEachLoop

Hi, I need to move n objects at the same time using 1 timeline, this to avoid copy-paste the same timeline n times for every object I need to move

alt text

So this code is not going to work, cause from what I understand the timeline can be played only on 1 object at time, and this code is trying to play it on several objects one after another, is there a way to archive this? Seems like a solution was given in this post but image link is gone.

Product Version: UE 4.20
screenshot-2.png (149.0 kB)
more ▼

asked Feb 03 '19 at 12:07 AM in Blueprint Scripting

avatar image

25 1 1 1

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

1 answer: sort voted first

loops run between frames so running a timeline in a loop wouldnt work. you could however use a for each loop after the timeline to set the location of many objects. or you could use one of the many other movement methods such as interps or add offset.

alt text

capture.png (156.3 kB)
more ▼

answered Feb 03 '19 at 01:02 AM

avatar image

10.1k 33 10 25

avatar image Steven991 Feb 03 '19 at 08:36 AM

This works if all my objects are in 0,0,0 I guess, in my bp all my doors are in different locations and I need to set the "Initial Location" for each one before start the timeline. Does this other methods allow me to animate my door with a curve like timeline?

avatar image ThompsonN13 Feb 03 '19 at 03:30 PM

below is another method you can try. it seems to work as you want in my initial testing. in the example we use a map instead of an array. the map will store the components to be moved and their associated initial relative location. as you can see in the picture when the event is called we first get all the components to be moved (i was getting all children in this case). then we use a for each loop to add the components to the map and at the same time get eaches location ans set that to the map as well. once we have created and populated the map we move on to moving the components via a timeline. to move each component we get an array of the keys it contains then use a for each loop as before to set the location. in this case however we are also getting the relative location associated with each key via the find node and using that as a reference point in the lerp.

this should all work as you like but i would caution that if you have many of these actors in your level then this may not perform well due to having so much to calculate each frame. if you only have a few of these actors it should be fine though and really it comes down to your target and optimization.

alt text

capture.png (346.2 kB)
avatar image ThompsonN13 Feb 03 '19 at 03:33 PM

oh and in your post you mention using this for doors. im guessing that your trying to do something like reset all the doors or open them all at once. if thats the case you could have each door as its own actor which would make things simpler, then you could use a event dispatcher to initiate each door to open or close itself. if you dont know about event dispatchers theres a great video by epic about blueprint communication which teaches all about it.

avatar image Steven991 Feb 03 '19 at 04:24 PM

Thank you very much for your 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