nataku

I want to use the same bone animation with different characters.
That character has a different mesh and a different weight.
We can put the same animation in each character's skeleton, but when we modify the animation, we have to modify as many characters as we can.
I am looking for ways to avoid this.

For example, we have two skeletons: an invisible skeleton with animation only, and a character skeleton without animation.
Is it possible to combine these two skeletons in Unity to create various characters with the same animation?
nataku
  • Posts: 6

Harald

Note that you could also use the Spine command line interface to import your animations to every character.

If you really want to do this on the runtime-side:
In spine-unity you can write your own code to append the animations of one skeleton data to another. You will most likely want to write your own SkeletonDataModifierAsset subclass. You can have a look at e.g. the AnimationMatchModifierAsset.cs file on how to iterate over the animations. You would then need to append the animations of one SkeletonData object to another.
User avatar
Harald

Harri
  • Posts: 2091

nataku

Harald wrote:Note that you could also use the Spine command line interface to import your animations to every character.

If you really want to do this on the runtime-side:
In spine-unity you can write your own code to append the animations of one skeleton data to another. You will most likely want to write your own SkeletonDataModifierAsset subclass. You can have a look at e.g. the AnimationMatchModifierAsset.cs file on how to iterate over the animations. You would then need to append the animations of one http://esotericsoftware.com/spine-api-reference#SkeletonData object to another.
Thank you for your reply.
I'm going to try it both ways.

I have a question.
It's a command line way to make a lot of characters have the same animation.
Is it possible to override a character's animation on the command line when you modify it later?
nataku
  • Posts: 6

Harald

nataku wrote:It's a command line way to make a lot of characters have the same animation.
Is it possible to override a character's animation on the command line when you modify it later?
I would not recommend to override parts of your worked-on project files via command line scripting. Instead it would be better to have the following folder structure:
animations
your-animation-set.spine
characters-without-animation
male-character.spine
output-animated-characters # <-- this folder contains only generated files
male-character-animated.spine
<or>
male-character-animated.json
So your command line script would not touch the original character spine projects, it would instead create combined files in the output-animated-characters folder. So you are safe to never loose any work, when e.g. your script does something wrong and corrupts or deletes the output file.

Explained differently: don't combine A and B to overwrite B, instead combine A and B to C.

Does this answer your question? Please let me know if you meant something different.
User avatar
Harald

Harri
  • Posts: 2091

nataku

Harald wrote:So your command line script would not touch the original character spine projects, it would instead create combined files in the output-animated-characters folder. So you are safe to never loose any work, when e.g. your script does something wrong and corrupts or deletes the output file.

Explained differently: don't combine A and B to overwrite B, instead combine A and B to C.
So you can use the command line to combine two spine projects and output one new spine project or JSON, right?
I don't have a deep understanding of the command line yet, but in terms of specific commands, are they something like the following?
When outputting a spine project
Spine -i /path/to/your-animation-set.spine -i /path/to/male-character.spine -o /path/to/output-animated-characters/male-character-animated.spine -r commonSkeletonName
To output json:
Spine -i /path/to/your-animation-set.spine -i /path/to/male-character.spine -o /path/to/output-animated-characters/ -e /path/to/export.json
nataku
  • Posts: 6

Harald

The commands look good to me. Please note that in -e /path/to/export.json the file export.json contains the description of the export, like in this file. Just to clarify that it will not export a skeleton named export.json.

You can have a look at the following script that we use to batch-export all example skeleton and atlas files at once:
spine-runtimes/export.sh at 3.8
User avatar
Harald

Harri
  • Posts: 2091

nataku

Thank you for the easy to understand explanation.
I'm going to try a lot of things on the command line! :)
nataku
  • Posts: 6

Harald

All the best with the export then! Just be caution when deleting files or be sure to have a backup ;)
User avatar
Harald

Harri
  • Posts: 2091

nataku

Harald wrote:All the best with the export then! Just be caution when deleting files or be sure to have a backup ;)
I tried this method, but it didn't work.
Trying to combine two spines into one spine and using the following command I did.
/Applications/Spine/Spine.app/Contents/MacOS/Spine -i ./dog/dog.spine -i ./anim/anim.spine -o ./output/output.spine -r outputSkeleton
The output.spine produced by this command is the same as the anim.spine was.
How do I combine the two spine?
dog.png
anim.png
スクリーンショット 2020-06-05 20.51.45.png
You do not have the required permissions to view the files attached to this post.
nataku
  • Posts: 6

Harald

The proper syntax for importing multiple files would be the following:
nataku wrote:Spine -i ./dog/dog.spine -o ./output/output.spine -r \n
-i ./anim/anim.spine -o ./output/output.spine -r
Oh dear, unfortunately I have just discovered that the command line interface currently always performs skeleton import - which means that you end up with two separate skeletons in the output Spine project file. Nate just told me that animation import is not yet possible via the command line, only from the Editor.
I'm very sorry about that :'( .
User avatar
Harald

Harri
  • Posts: 2091

nataku

Harald wrote:Oh dear, unfortunately I have just discovered that the command line interface currently always performs skeleton import - which means that you end up with two separate skeletons in the output Spine project file. Nate just told me that animation import is not yet possible via the command line, only from the Editor.
I'm very sorry about that :'( .
Thanks for the reply . I hope to be able to do this on the command line soon.
nataku
  • Posts: 6


Return to Unity