I'm making a game where a line is drawn between two moving objects. I want to make multiple instances of this setup that are created during gameplay, so I'm saving an "id" for each object and having the line (which is a 1x1px object) connect between the start and end objects by using three foreach loops:
- For every line object, start a loop on the start objects
- For every start object, if it has the same id as the line object, start a loop on the end objects
- For every end object, if it has the same id as the line object, position the line on the start object and connect it between that and the end object (using scale and rotation.
It works perfectly fine with just one setup, but once I add another one with a different id, the line from the first setup connects to the end object from the second setup... even though I can confirm with the debugger that they have different IDs. If I add a check on the third loop to make sure the start object has the same id as the line, then both lines end up following the newly created setup.
I also tried having the loop begin with the start and end objects instead, but doing that caused the first line to stop connecting once the second setup was created.
I've attached an example of the code. Please let me know if I did something wrong or if Fusion just doesn't support foreach like this... if so, is there a better way of doing what I'm trying to do?
Please login to see this attachment.