[Solved] Syncing animations of multiple object instances


#1

Is there a way to make sure that multiple instances of the same object have their animations synced up throughout a level?

For example, say I have a coin with a rotation animation that is made of 8 images. I place the coins throughout the level. As I progress through the level, the coins do not all spin in sync. I would imagine this has to do with an object not “starting” until it comes into/near the viewport…but I really don’t know. I’ve played around with “Change Frame” but can’t find a way to get that to work for this.


#2

Yes, it seems to be the case. I’m not sure if there is any way to override this but I know a solution that is not pretty and probably not practical, but works.

  1. Create a new layer name it for example “animation”.
  2. Create a copy of the object you want to sync and put it on the “animation” layer
  3. You can hide the copy on the “animation” layer to be not visible.
  4. To sync the animation of all instances, compare their current animation frame with the current image of the copy on the “animation” layer and if it’s different, set the animation frame of the object to be the same as the animation frame of the copy on the “animation” layer.

The event should look something like this:
The animation frame of Object is NOT = objectCopy.Sprite() THEN Change the animation frame of Object to objectCopy.Sprite()

Where “Object” and “objectCopy” is the name of the objects.

This way you can force all instances to keep the animations in sync by copying the frames from the object copy.
The reason we need to put the copy on it own separate layer is that if you move the camera and you leave the copy behind, it is going to stop playing the animation so in order to keep it on the screen constantly, we put it on it own layer.

This is a really dirty solution and if you have lots of sprites, it may even going to cause performance problems, but at the moment, this is the only solution I have.

Would like to know if there is any better solution.


[Résolu] Synchronisation des animations
#3

In case anyone is reading this in the future looking for a solution…this works! However, I found that if I hid the objectSync then it didn’t work, so I just placed it slightly off the window boundary. Works great!