r/forgescripting • • Nov 19 '22

For Each Object--how does it work?

I'm trying to make a series of objects all move at the same time, but when I use the [For Each Object] node, it makes them move one at a time, according to their order in the object list. How can I make them move simultaneously, or at least reduce the amount of time between them? Am I using the wrong node for this kind of thing?

Honestly, I just don't quite grasp the logic behind some of these nodes yet; I just have no idea what some pins are supposed to connect to. [For Each Object]'s last pin, for instance: "current iteration." What can that connect to? What's it for?

3 Upvotes

9 comments sorted by

View all comments

Show parent comment

3

u/0mni42 Nov 19 '22

To get around this limitation, you can just wire up multiple event sources instead of relying on the object loop, but that may be impractical for certain situations.

Yeah, that's what I'm trying to avoid. In short, I'm making a door with eight "teeth" that dilate open; making a separate script for each tooth is a pain and I'm looking for a way to do it more efficiently. There must be a way to apply a script to objects in a list simultaneously; it would be a baffling thing to not include.

2

u/Schmeck Nov 19 '22

Have you tried looking into custom events? I haven’t tested out this scenario myself, but you may be able to trigger a custom event for each object in the list that would run each movement action independently.

3

u/0mni42 Nov 20 '22

I've been looking into that yeah, though once again I don't quite understand what the terminology means and what I'm missing. I keep getting "On Custom Event node missing information; node graph failed to build" errors, and I don’t understand why.

3

u/Schmeck Nov 20 '22

Well I can save you the time! I tried to use a custom event that passed a reference to the current object, but that still resulted in a sequential movement. I even tried passing just the current index through the event and got the same result. I think until we get some way to explicitly perform simultaneous movements, the best workaround would be to just wire up a separate event to each of the pieces you are looking to move, unfortunately.