How do I rotate every object in a chain?

Get help using Construct 2

Post » Wed Aug 10, 2016 12:01 am

Preferably without using the For Each loop. Maybe I'm missing an obvious solution so I'm taking a step back here.

Think of a train with several cars attached to the locomotive. Each car is Pinned to the one before it, and each tries to rotate towards the position of the one it's pinned to for a natural, flowing effect. Now, I was able to do it easily enough using a For Each loop, but, this results in a pretty severe fps drop when there are a lot of cars and trains. Not having a For Each loop in the event apparently makes it not work altogether. So, is there a way to do this without a For Each loop?

Thanks for any help.
B
50
S
23
G
17
Posts: 291
Reputation: 12,432

Post » Wed Aug 10, 2016 12:14 am

If the objects are in index order then just go sprite(self.iid-1).angle.
Which works for all, but the first indice.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Wed Aug 10, 2016 5:38 am

That... works for the most part! Only issue seems to be having multiple locomotives, which results in the first car of one train turning to face the last car of another one since they're instances of the same object. However, it seems I was able to get around it by assigning custom IDs and Pinning by position & angle in this case.

Anyway, works lovely now, big thanks!
B
50
S
23
G
17
Posts: 291
Reputation: 12,432


Return to How do I....?

Who is online

Users browsing this forum: lukewasthefish, Mayfly, tarek2 and 16 guests