Hypothetical Script for Swapping Sprites and Applying Animation Automatically

This is about 2d animation and scripting.

So it would be simple for me to animate my base character without equipment, then animate every little piece of armor and weapon and then create a get value script to apply the changes with a quick “saving changes” status bar. Unfortunately it would be insanely time consuming.

There might be a much faster way. If I have all of the equipment at a similar position, breastplate at the center of torso or sword hilt on hand central point with sword spine at aligned slope with original, it should be possible to code a “box” of sorts that is animated and moves the contents along with it.

Now comes my problem: I have no idea how to code anything that complex, nor do I know many of the options given to me by this engine. It would take a village, or maybe a wizard. Perhaps just two hobbits, a magic ring, and a hobgoblin. Any help would be greatly appreciated, while clutter is not.

There’s no real code involved at all. Use the hierarchy to your advantage and set the armour pieces as children of the appropriate GameObject.

So say your hierarchy looks like this with nothing equipped:

Character
>Hips
>>Torso
>>>Head
>>>Left Arm
>>>Right Arm
>>Leg Leg
>>Right Leg

To equip gear, just set it to the child of the appropriate bone part and it will move in tandem with its parent.

Character
>Hips
>>Torso
>>>Breasplate
>>>Head
>>>>Helmet
etc etc
1 Like

This is how I have been animating my 2D characters. I make bones with joints then apply the sprites to each bone. I then animate the rotation of the joints to make walking, running, jumping, etc…

The hierarchy looks like this on a Ninja I made for my current game.
2244642--149890--TwoDHierarchyExample.jpg
The names are not quite right for an example. Pelvis could be changed to Spine, LeftArmJoint is the left shoulder. The knees and ankles are joints.

I can then swap sprites or even add another on top of which ever one I want. I also animate the head by swapping the sprites for the head to the different facial expressions using regular animations with triggers, this also requires using animation layers. This is the more complicated part of animating a character 2D or 3D. The script is pretty basic, it gets large with all the parts that can be changed, but its simply changing the right sprites for the right parts.

Perfect, thank you all for your help. I’ll start practicing this right away.