
I load .x file with animations clips ( hierarchal animations ) , the animations in my file splitted from 0 to 400 ( walk , run ......etc ) , I create instance of character controller and it's move correctly with the model.x file , I look at the documentation of your Norbo and you says in your library that " ChrachterController.Body.CollisionInformation.LocalPosition " localPosition is used to offset the collision geometry , so I do what you said :
Code: Select all
public void LoadContent(ContentManager Content)
{
#region Enemy
Model model = Content.Load<Model>("Models//Beast//beastmodel");
enemyAnimator = new ModelAnimator(game, model);
idle = new AnimationController(game, enemyAnimator.Animations["idle"]);
// Add this in LoadGraphicsContent
run = new AnimationController(game, enemyAnimator.Animations["Jump with no Z movement for control in-game"]);
walk = new AnimationController(game, enemyAnimator.Animations["walk"]);
crouch = new AnimationController(game, enemyAnimator.Animations["crouchDown"]);
stayCrouched = new AnimationController(game, enemyAnimator.Animations["stayCrouched"]);
killed = new AnimationController(game, enemyAnimator.Animations["Die"]);
attak = new AnimationController(game, enemyAnimator.Animations["Bite 2"]);
// Add Enemy to Physics Space
enemyChrachterController = new CharacterController();
enemyChrachterController.HorizontalMotionConstraint.Speed *= 20;
enemyChrachterController.HorizontalMotionConstraint.CrouchingSpeed *= 10;
enemyChrachterController.HorizontalMotionConstraint.MaximumForce = 5000;
enemyChrachterController.HorizontalMotionConstraint.MaximumAirForce = 5000;
enemyChrachterController.Body.Tag = "noDisplayObject";
enemyChrachterController.Body.Height = 80;
enemyChrachterController.Body.Radius = 40;
enemyChrachterController.Body.Position = dwarfPosition ;
Vector3 center = enemyChrachterController.Body.CollisionInformation.LocalPosition;
enemyChrachterController.Body.WorldTransform *=
Matrix.CreateTranslation(-center);
space.Add(enemyChrachterController);
RunController(enemyAnimator, idle);
#endregion
}
void Update(GameTime gameTime, KeyboardState keyboardInputt,
KeyboardState previousKeyboardInputt, MouseState mouseInput)
{
#region Enemy
enemyAnimator.World = Matrix.CreateScale(5) * rotationModel *Matrix.CreateTranslation(enemyChrachterController.Body.CollisionInformation.LocalPosition)*
enemyChrachterController.Body.WorldTransform;
foreach (ModelMesh mesh in enemyAnimator.Model.Meshes)
foreach (Effect effect in mesh.Effects)
effect.Parameters["View"].SetValue(camera.ViewMatrix);
#endregion
}
Norbo the Model is still in the air and not touching the ground but move correctly with the physics entity ??
Norbo every thing works great , when I am close to enemy he follow me by applying force to character controller then the model.x follow but the model.x is offsets from the ground and I think it's because center of mass because the model.x 100% collide and behaviors greatly .