rigging bones to work with scripted motion

General Moho topics.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
EricTheFish
Posts: 91
Joined: Thu Jun 15, 2017 4:37 pm
Location: Lymm, UK

rigging bones to work with scripted motion

Post by EricTheFish »

I want to make a cyclist character where the character's feet follow the pedal rotation. The idea being, the faster the pedals go round, the faster he pedals.

I'm using a simple test file to explore the rigging principles along with this great script by STAN "http://mohoscripts.com/script/sz_rotating_bone" which rotates the bike's pedals and wheels relative to the X position of the character root bone.

Effectively the faster the character moves along X, the faster the wheels and pedals go round. So far so good, works perfectly!

The problem I'm having is finding a way to rig the character's feet to stick the pedals. You can't target a bone that is already parented and the pedal bones are parented to the rotating axle bone controlled by the script.

Is what I'm trying to achieve possible?

It would be great to able to move the character around and let the wheels and pedalling legs sort themselves out automatically speedwise!
EricTheFish
Artist, musician, animator, coder and dabbler in stuff
www.tech-nique.co.uk
User avatar
alanthebox
Posts: 216
Joined: Sat Feb 03, 2018 5:31 pm
Contact:

Re: rigging bones to work with scripted motion

Post by alanthebox »

Hmmm... I wonder if you could use this script?

viewtopic.php?f=12&t=34028
Daxel
Posts: 1088
Joined: Wed Mar 27, 2019 8:34 pm

Re: rigging bones to work with scripted motion

Post by Daxel »

That script is super elegant. Congrats Stan.
I havent tried it, and this other one neither, but I have a feeling that this other amazing script from Mult Rush could help you to achieve that. It was made to do something similar, to make a bone follow the movement of another bone when you can't use targets, but the reason being that the other bone is in a different bone layer. I don't know if you can use it for bones of the same layer, and if not, maybe you can explore the idea of using different bone layers for the bicicle and the character (that wouldn't be a bad idea if you want to be able to easily reuse the bicicle I guess).

Take a look, it has a video tutorial:
https://www.youtube.com/watch?v=r5LB2co8dzk

And the script:
http://mohoscripts.com/script/mr_track_bone

Again, I haven't tried it but hope it works like I think!
Daxel
Posts: 1088
Joined: Wed Mar 27, 2019 8:34 pm

Re: rigging bones to work with scripted motion

Post by Daxel »

alanthebox wrote: Tue Aug 17, 2021 5:29 pm Hmmm... I wonder if you could use this script?

viewtopic.php?f=12&t=34028
I'm too slow writing in english xD
User avatar
SimplSam
Posts: 1218
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: rigging bones to work with scripted motion

Post by SimplSam »

EricTheFish wrote: Tue Aug 17, 2021 5:16 pm ... You can't target a bone that is already parented and the pedal bones are parented to the rotating axle bone controlled by the script. ...
I am not aware of any such 'parented' restriction. I have similar feet/pedal rigs (w/ smartbone driven pedal rotation) - and there is no issue getting feet to follow pedals using target bones that have parents.
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Re: rigging bones to work with scripted motion

Post by chucky »

Why not use the old strategy of a smart action controlling the speed of the cycle?

Make te cycle then a new smart bone which at its full on position matches the cycle going many times.

The slower you move that bone toward the final position in the mainline, the slower the cycle rotates.

Super effect and fun to use.

Victor came up with that one (I think), it's a beauty.
User avatar
synthsin75
Posts: 10280
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: rigging bones to work with scripted motion

Post by synthsin75 »

To do that using Stan's script, it would have to be modded to write keyframes for the rotating bone.

If you wanted to do it with a smart bone, you'd just have to have the wheel rotation control the root bone's translation.
User avatar
SimplSam
Posts: 1218
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: rigging bones to work with scripted motion

Post by SimplSam »

For the question of Feet tracking Pedals - I have pulled the relevant config from a previous piece of work.
In the following simplified example the only thing that is keyframed is the rotation of the 'crank' pin bone (2 keyframes). This rotation could equally be controlled by script or smart bone.
For all other animation:
- The Pedals (@pedal L/R) are parented to the Crank and rotate when it does (w/ Independant Angle)
- The lower Leg bones (leg Low L/R) target the respective Pedals
- The Feet (foot L/R) are parented to the lower Leg bones (leg Low L/R) (w/ Independant Angle)
- The upper Leg bones (leg Up L/R) are driven by IK
- The entire rig has parenting descended from root to allow positional movement of the whole rig

Project File: https://drive.google.com/file/d/1uS70Wt ... sp=sharing

Image
Image
Image
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
Lukas
Posts: 1336
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: rigging bones to work with scripted motion

Post by Lukas »

synthsin75 wrote: Wed Aug 18, 2021 2:16 amTo do that using Stan's script, it would have to be modded to write keyframes for the rotating bone.
I’ve made a wheels layerscript that keys the animation (it only keys the necessary frames). I’ll post it here later.
User avatar
slowtiger
Posts: 6257
Joined: Thu Feb 16, 2006 6:53 pm
Location: Berlin, Germany
Contact:

Re: rigging bones to work with scripted motion

Post by slowtiger »

I found it much easier to rig the biker's legs from the bottom up: pedal pivot is root, then go up until thigh. This way the feet always stay on pedals. The missing connection between thigh and hip I could easily hide in the black shorts my biker was wearing. (This was done years befor target bones, so maybe there's a nice trick there.)
http://slowtiger.de/examples/biker_24_2.mov
AS 9.5 MacPro Quadcore 3GHz 16GB OS 10.6.8 Quicktime 7.6.6
AS 11 MacPro 12core 3GHz 32GB OS 10.11 Quicktime 10.7.3
Moho 13.5 iMac Quadcore 2,9GHz 16GB OS 10.15
Moho 14.1 Mac Mini M2 Pro OS 13.7.6
User avatar
EricTheFish
Posts: 91
Joined: Thu Jun 15, 2017 4:37 pm
Location: Lymm, UK

Re: rigging bones to work with scripted motion

Post by EricTheFish »

SimplSam wrote: Tue Aug 17, 2021 8:11 pm
EricTheFish wrote: Tue Aug 17, 2021 5:16 pm ... You can't target a bone that is already parented and the pedal bones are parented to the rotating axle bone controlled by the script. ...
I am not aware of any such 'parented' restriction. I have similar feet/pedal rigs (w/ smartbone driven pedal rotation) - and there is no issue getting feet to follow pedals using target bones that have parents.
Sorry Sam I wasn't clear. I was talking about this scenario where the parented "target" bone is being manipulated by the script. My efforts to make another bone respond to the moving "target" failed. It just ignored the bone constraint settings.

I imagine it's probably because there are no bone keyframes to reference, the target bone X/Y position data is script generated, not physical.
EricTheFish
Artist, musician, animator, coder and dabbler in stuff
www.tech-nique.co.uk
User avatar
EricTheFish
Posts: 91
Joined: Thu Jun 15, 2017 4:37 pm
Location: Lymm, UK

Re: rigging bones to work with scripted motion

Post by EricTheFish »

alanthebox wrote: Tue Aug 17, 2021 5:29 pm Hmmm... I wonder if you could use this script?

viewtopic.php?f=12&t=34028
Actually, I have already tried Mult Rush's wonderful target bone script and it does sort of solve the problem in a roundabout way.
It generates lots of keyframes that mirror the target bone position and movement, so this is great tool if some animation is already finalised and you just need to link something to it.

I guess I was excited with the idea that I could make a bicycle rig that I could move around freely and only need keyframes for the root bone X position. Moho would magic the rest.

Lots of interesting suggestions and alternative ideas from everyone. I'll investigate those too. There are more ways to skin a cat, as they say!
EricTheFish
Artist, musician, animator, coder and dabbler in stuff
www.tech-nique.co.uk
User avatar
EricTheFish
Posts: 91
Joined: Thu Jun 15, 2017 4:37 pm
Location: Lymm, UK

Re: rigging bones to work with scripted motion

Post by EricTheFish »

chucky wrote: Wed Aug 18, 2021 2:11 am Why not use the old strategy of a smart action controlling the speed of the cycle?

Make te cycle then a new smart bone which at its full on position matches the cycle going many times.

The slower you move that bone toward the final position in the mainline, the slower the cycle rotates.

Super effect and fun to use.

Victor came up with that one (I think), it's a beauty.
Chucky, I'm not quite seeing how this is constructed. My SB adjusts the cycle speed but the cycle stops when the smart bone is at max.
Do you have an example, I'm doing something wrong! :(
EricTheFish
Artist, musician, animator, coder and dabbler in stuff
www.tech-nique.co.uk
User avatar
SimplSam
Posts: 1218
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: rigging bones to work with scripted motion

Post by SimplSam »

EricTheFish wrote: Wed Aug 18, 2021 11:10 am Sorry Sam I wasn't clear. I was talking about this scenario where the parented "target" bone is being manipulated by the script. My efforts to make another bone respond to the moving "target" failed. It just ignored the bone constraint settings.
I imagine it's probably because there are no bone keyframes to reference, the target bone X/Y position data is script generated, not physical.
OK - I have now seen the issue. I think the problem here is local vs global bone position. i.e. Whilst rotating the pedals (in this setup) the target bone does not move relative to its parent, so in reality the targeting bone has to target the pedals global position. This is all normal and the targeting system normally calculates for the global position. I can only guess that when the script is used, it effectively bypasses some required recalculation of the global position of the target.

Based on that theory, and after some playing around - I have a hack that appears to trigger the required bone targeting update. It adds, updates and then removes a keyframe on the "Wheel" bones' rotation channel.

If you find and replace the line:

Code: Select all

                bone.fAngle = angle
with:

Code: Select all

                if (bone.fAngle ~= angle) then
                        bone.fAngle = angle
                        bone.fAnimAngle:SetValue(moho.frame, angle)
                        moho.layer:UpdateCurFrame()
                        bone.fAnimAngle:DeleteKey(moho.frame)
                end
Not sure if this is an optimal solution, but I think it will do for now - until something better comes along.
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
EricTheFish
Posts: 91
Joined: Thu Jun 15, 2017 4:37 pm
Location: Lymm, UK

Re: rigging bones to work with scripted motion

Post by EricTheFish »

SimplSam wrote: Wed Aug 18, 2021 5:15 pm Not sure if this is an optimal solution, but I think it will do for now - until something better comes along.
Absolutely perfect solution Sam. Works like a dream sir!

I had just successfully found a reasonable workaround too.
I renamed the pedal axle bone to remove it from script influence and made a new "helper" bone that follows the rotating wheel script instead.
Then I used an angle controller to link the axle bone to the new helper bone and voila! The rig works too! Target bones work as normal.
So, by just moving the root bone, the bike wheels rotate relative to X distance moved and the cyclist pedals like an Olympian!

I now have two methods that produce the same effect! :)

Many thanks for your help, much appreciated!
EricTheFish
Artist, musician, animator, coder and dabbler in stuff
www.tech-nique.co.uk
Post Reply