Le_Dieu_du_fond_du_Jardin/docs/spine.md
2020-05-07 17:33:05 +02:00

2.9 KiB

Using Spine

Spine is an animation program that is not officially supported by Godot, but there exists a Spine module that can be added to the modules/ directory in your Godot source tree and built with eg. schedtool -D -e ccache scons platform=x11 tools=yes target=release_debug or whatever you like.

For compatibility with Godot, run spine-to-godot-scene.py ("the script"), found in the Spine to Godot project, from your project root (typically the device/ directory).

Do note the script requires python3-docopt, so please install it using pip3 or whatever you prefer. You may also want to read its documentation; it may expand to cover things not in the scope of Escoria!

Caveats

Do note that Spine animations cannot be played in reverse by design.

Prerequisities

If you have different skins for your Spine skeletons, and multiple files for eg. moving in different directions, make sure they're named exactly the same. The script will do its best to make this easy for you to use.

Do not use whitespaces anywhere; Escoria will not understand whitespaces, even if Godot would.

Creating Spine scenes

Copy your Spine data under eg. items/foo/. This can be the player or an NPC or even just an item.

Use the script to generate a scene in the same items/foo/.

The script generates a scene with a Spine node and animations. These animations are autogenerated and have horrible names, but they're there.

Using Spine scenes

To enable interoperability between Spine and eg. shadows, or other nodes that don't want to be flipped when the character is flipped, create a Node2D node called sprite and put the Spine node(s) under it.

To avoid editing and using the autogenerated animations, go to the animation editor and for every relevant animation, make a copy and rename it.

Looking at the Spine node, you'll have to select the different animations to get their durations. Unfortunately there is no other way now to get them.

Update your copied animation with the relevant information (like duration), add tracks, or whatever your project requires.

Examples

Changing skins

Make a copy of the spine_character__skin__blue style animations to call it skin_blue.

Now you must run the animation in your game: cut_scene player skin_blue. It's not really a cut scene, but this is how we guarantee it finishes before anything else happens. To make your player idle after that, run set_state player idle.

Moving around

Because your movement directions will likely be in different files, you will get multiple visible Spine nodes when moving.

The solution is to copy an animation like spine_character_front__move_down and call it move_down. Then you add tracks to it that hide the other Spine nodes for the duration of the animation.