Using 1 animation for multiple objects

Can I create 1 animation to move many different objects only on 1 of the axises at a time?

Screenshot by Lightshot - In this example with 1 anim to move all the objects to the right exactly like the bottommost one. For example with 300 units each to the right only. But not to go down to the Y of the bottommost object but to keep their Y values. How can I achieve this?

I think you can do this a couple ways actually.

  1. Using just Unity: Create an Animation in your Assets folder. Put a dummy cube in your scene. Drop the Animation onto it. Select the dummy cube in the hierarchy. Press ctrl+6 to open the Animation panel. Click Add Curve, then expand the new node on the left and add a transform curve. Manually key in your movement on the axis you want, then close the Animation panel. You can now drop that Animation on anything, and it will perform the same way on everything. You’ll have the exact same animation however. So everything will be sitting on top of each other. So to get around that you create parent gameobjects that all sit at (0,0,0) and then apply the Animation to those. Inside those just offset the sprite gameobjects up a couple units each so they aren’t overlapping.

  2. Using 3d Modeling Software: If you have access to blender or some other 3d program, you could create a simple skinned model with animation on it. Then skin the other models the same way and name the single root joint on all of them the same. Then just open up the model in the Projects folder after importing and drag it into an AnimationController that you share between all 3 models. A bit of overkill, really.

Another way is to create a game object to hold all of the objects you want to animate and then when you create an animation for the parent wrapper object, click “add property “ and you can add properties for the children objects to change within a single animation.

If the animation is simple, like moving the transform to the right say 100 unity metres, then it will work on any object.
But if it would be like an animation of something specific to that object, it wouldn’t be able to animate a different object .

So you can create 1 animation for an object and apply it to many then activate these animation whenever you want.