How to animate feet (scripting) and have ground move same speed (no slipping)?


#1

Hello all!

I am working on a project where I have to script the animation of a quadruped walk and run cycle. The walk cycle isn’t hard, with a sin function for up and down motion and cos or -cos for the forward and back motion. Yet I don’t get how to make the ground move with the feet at the exact speed they are moving. After all, if I assign a sin or cos function to the ground it will move back and forth, as it goes from 1 to -1 and back in a cycle.

Here is my code so far:

$amp = 2; //controls height of foot during animation
$ampz = 3; //controls forward and back motion of foot during animation

if(frame < 100) //speed up for 100 frames then stop, as a test to see the code is working
$speed = 3+time*2;
else
$speed = 0; //this is to just test if they object will stop at frame 100, will later add in whatever the heck slows it down.

$footmove = $ampzcos($speedtime); //front foot
$footmove2 = $ampzcos($speedtime+3.14); //back foot
$footup = $ampsin($speedtime); //front foot y motion
$footup2 = $amp*-sin($speed*time); //back foot z motion

foot.translateX = $footmove;
if($footup >= 0)
foot.translateY = $footup;
else
foot.translateY = 0;

foot2.translateX = $footmove2;
if($footup2 >= 0)
foot2.translateY = $footup2;
else
foot2.translateY = 0;

ground.rotateZ = -1*($amp*$speedtime.43);
/ground object rotation (huge cylinder on side, so it can rotate and close up it looks flat/


#2

this code for which game can you post more info than i can solved your problem