Page 1 of 2

rigging bones to work with scripted motion

Posted: Tue Aug 17, 2021 5:16 pm
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!

Re: rigging bones to work with scripted motion

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

viewtopic.php?f=12&t=34028

Re: rigging bones to work with scripted motion

Posted: Tue Aug 17, 2021 5:35 pm
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!

Re: rigging bones to work with scripted motion

Posted: Tue Aug 17, 2021 5:36 pm
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

Re: rigging bones to work with scripted motion

Posted: Tue Aug 17, 2021 8:11 pm
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.

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 2:11 am
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.

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 2:16 am
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.

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 6:57 am
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

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 7:31 am
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.

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 9:04 am
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

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 11:10 am
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.

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 11:25 am
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!

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 1:25 pm
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! :(

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 5:15 pm
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.

Re: rigging bones to work with scripted motion

Posted: Wed Aug 18, 2021 6:32 pm
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!