Toggle Parent Bone - A tool to toggle the relationship between a bones translations and root

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
SimplSam
Posts: 1048
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Toggle Parent Bone - A tool to toggle the relationship between a bones translations and root

Post by SimplSam »

see also: How to counter translation for game sprites?

This tool toggles the parental relationship between one or more designated bones (typically target bones) and a "Root" bone - taking into account the designated bones existing keyframed translation animation. Allowing you to localise the designated bones (reparent them to "Root"), before editing or reanimating the "Root" bones' movement, then setting the designated bones back to their original unparented globally positioned state.

This tool & technique can be used to contain or isolate a characters existing movement & animation (typically those that use unparented Target bones) - such that the character can be made to run/walk/jump/animate 'on the spot' - as might be required for Sprite animation or similar.

Image
Example A: After removing X translation of the "root" bone

Howto (typical use):
- Select one or more Target bones (can be any bone - but typically target & unparented)
- Click (run) the 'Toggle Parent Bone' tool to: Attach the selected bones to the "root" bone and adjust their transforms to make them relative to "root" (*1)
- (optionally) Review the new Parent relationship using the standard reparent bone tool
- Add/Edit/Remove any desired "Root" bone movement (*4)
- ReSelect the Target bones
- Click (run) the 'Toggle Parent Bone' tool to: Detach the selected bones from the "root" bone and adjust their transforms to make them global again
- Review the new animation

Image
Example B: After removing X translation of the "root" bone

Notes:
There are a few caveats with this (v1.0) release:
1) The tool currently assumes the "Root" bone to be the first defined bone (top of bone list is Select Bone drop down). You don't actually need to reparent to the actual root bone for this to work, but any bone that moves inline with root should work OK
2) The animation may look funny / broken when Target bones go from Global to Local (parented), but should be OK again once you toggle them back
3) The tool only attempts to target/fix the translation of selected Target bones
4) I have found that animations seem to rework best - when the "Root" bone Y transforms are unchanged and X is removed/altered (with Separated Dimensions). Your requirements & mileage may vary
5) A dialog for Root/Parent selection is planned
6) ** The tool will ignore & ultimately remove any existing re-parenting keyframes on the selected target bones

The tool can be downloaded here: ss-moho-toggle-parent-bone.zip
Last edited by SimplSam on Sat Oct 16, 2021 1:05 am, edited 4 times in total.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
Daxel
Posts: 996
Joined: Wed Mar 27, 2019 8:34 pm

Re: Toggle Parent Bone - A tool to toggle the relationship between a bone translations and root

Post by Daxel »

Impressive work!

I just tested it a little bit with a rig and the tool is amazing. I didn't expect it to work so well, be so easy to use and so flexible. I was afraid it would delete all the root bone animation in the process, but the way you designed the tool giving the user the choice is perfect because each case may need different tweaking. As you said, in most cases removing the horizontal (x) movement is the way to go, because it allows the character to keep its vertical bouncing for example when running. In a matter of seconds my running animation was a game sprite.

I will keep testing it with more animations and trying to understand what the tool does. I have the feeling that is going to be useful for more than turning normal animations into sprite animations.

Thank you so much!
Daxel
Posts: 996
Joined: Wed Mar 27, 2019 8:34 pm

Re: Toggle Parent Bone - A tool to toggle the relationship between a bones translations and root

Post by Daxel »

An update on my experiences with this great tool:


Important aditional use case: allows for greater animation reusability

As I imagined when I saw it working for the first time, I ended finding more uses than the original one. Basically it allows me to easily reuse animations that contain target bones. When you want to reuse one of those, because the animation you want to reuse contains global positions of the target bones, it will only work well if you paste the animation on a character that is on the exact same position. With this tool you are able to make those targets positions of the animation you want to reuse relative to the root of the character (not global anymore) without having to remake the animation and therefore your animation is now easily reusable.
I know that you, Sam, don't need that explanation but I wanted to make it clear for the users that may read this, because it is indeed a tool that not only sprite animators, but every animator, can benefit from.


Sharp corners

The bone that the tool takes as root bone sometimes is not the correct one. As you said, it takes the first created bone and, even if in most cases it is the root bone, sometimes is not.

Even if the position of the target bones gets baked perfectly, their rotation seems to get inverted automatically. For example, if your target bones were normal bones (not pin bones) and they were looking up in your original animation, the tool makes them look down. In most cases, it doesn't matter, as only the position of a target bone is relevant for the animation, but when I tried to use this tool on a character rig whose arms were unparented (global), they changed their direction to the opposite side.

Thank you again!
Post Reply