private void InitaliseAnimations(UpdateManager updateManager) { //create the controller as an asynchronous controller. //this will process animations as a thread task //This occurs between the update loop and the draw loop, //which is why the UpdateManager must be provided. control = model.GetAsyncAnimationController(updateManager); //these perform a linear search to find the animation index int idleAnimationIndex = control.AnimationIndex("Loiter"); int jogAnimationIndex = control.AnimationIndex("Jog"); int walkAnimationIndex = control.AnimationIndex("Walk"); //create the idle animation idle = control.PlayLoopingAnimation(idleAnimationIndex); //give it a random speed idle.PlaybackSpeed = (float)random.NextDouble() * 0.5f + 0.6f; if (moveSpeed > 0.75) { //run animation move = control.PlayLoopingAnimation(jogAnimationIndex); // play a jogging animation move.PlaybackSpeed = 0.5f; } else { //walk animation move = control.PlayLoopingAnimation(walkAnimationIndex); // play a walking animation } //initially don't want the move animation being visible move.Weighting = 0; }
public Actor(ContentRegister content, UpdateManager updateManager) { //load the model model = new ModelInstance(); content.Add(this); //create the animation controller animationController = model.GetAsyncAnimationController(updateManager); //NEW CODE //create the animation modifier int rotateBoneIndex = model.ModelData.Skeleton.GetBoneIndexByName("Bip01_Spine2"); this.animationModifer = new AnimationModifier(rotateBoneIndex, model.ModelData); //set the modifier on the animation controller this.animationController.AnimationBoneModifier = this.animationModifer; //play the run animation int animationIndex = animationController.AnimationIndex("Jog"); this.animation = animationController.PlayLoopingAnimation(animationIndex); }