function Update() {
RunZ("RunFLeftLeg", "RunFRightLeg", "RunBLeftLeg", "RunBRightLeg");
RunX("RunLeft", "RunRight");
lastStep = controller.del;
}
......................................................................................
function RunX (Left : String, Right : String) {
if(controller.onStep == true && controller.onStep != controller.lastStep) {
if(Mathf.Abs(controller.MoveSpeedX) > Mathf.Abs(controller.MoveSpeedZ)) {
if(controller.MoveSpeedZ < 0)
MoveX(Right, Left);
else
MoveX(Left, Right);
}
else {
.......................................................................
}
}
}
........................................................................................
function MoveX(Left : String, Right : String) {
if(controller.MoveSpeedX > 0)
PlayAnimX(Right, weightMod);
if(controller.MoveSpeedX < 0)
PlayAnimX(Left, weightMod);
}
........................................................................................
function PlayAnimX(anim : String, weightModifier : float) {
var weight = Mathf.Clamp((Mathf.Abs(controller.MoveSpeedX) / weightModifier), 0, 1);
animation[anim].speed = (animation[anim].length) / controller.del;
animation.Blend(anim, weight, (controller.del / 2));
}