|02 February 2017|
How to animate feet (scripting) and have ground move same speed (no slipping)?
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:
Quote: $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;
$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 = $ampz*cos($speed*time); //front foot
$footmove2 = $ampz*cos($speed*time+3.14); //back foot
$footup = $amp*sin($speed*time); //front foot y motion
$footup2 = $amp*-sin($speed*time); //back foot z motion
foot.translateX = $footmove;
if($footup >= 0)
foot.translateY = $footup;
foot.translateY = 0;
foot2.translateX = $footmove2;
if($footup2 >= 0)
foot2.translateY = $footup2;
foot2.translateY = 0;
ground.rotateZ = -1*($amp*$speed*time*.43);
/*ground object rotation (huge cylinder on side, so it can rotate and close up it looks flat*/
|reply share thread|