private Game3DObject CreateZombie(Loader loader) { var body = loader.MakeRectangle(Vector3.Zero, Vector3.Zero, Vector3.One + Vector3.UnitY * 3 + Vector3.UnitX * 2); var leftLegBone = loader.MakeRectangle(Vector3.UnitY * -4 + Vector3.UnitX * -2, Vector3.Zero, Vector3.One * 1.2f); var rightLegBone = loader.MakeRectangle(Vector3.UnitY * -4 + Vector3.UnitX * 2, Vector3.Zero, Vector3.One * 1.2f); var leftArmBone = loader.MakeRectangle(Vector3.UnitY * 3 + Vector3.UnitX * -4, Vector3.Zero, Vector3.One * 1.2f); var rightArmBone = loader.MakeRectangle(Vector3.UnitY * 3 + Vector3.UnitX * 4, Vector3.Zero, Vector3.One * 1.2f); var headBone = loader.MakeRectangle(Vector3.UnitY * 4, Vector3.Zero, Vector3.One * 1.1f); body.AddChild(leftLegBone); body.AddChild(rightLegBone); body.AddChild(leftArmBone); body.AddChild(rightArmBone); body.AddChild(headBone); var leftLeg = loader.MakeRectangle(Vector3.UnitY * -3, Vector3.Zero, Vector3.One + Vector3.UnitY * 3); var rightLeg = loader.MakeRectangle(Vector3.UnitY * -3, Vector3.Zero, Vector3.One + Vector3.UnitY * 3); var leftArm = loader.MakeRectangle(Vector3.UnitY * -3, Vector3.Zero, Vector3.One + Vector3.UnitY * 3); var rightArm = loader.MakeRectangle(Vector3.UnitY * -3, Vector3.Zero, Vector3.One + Vector3.UnitY * 3); var head = loader.MakeRectangle(Vector3.UnitY * 2, Vector3.Zero, Vector3.One * 2); leftLegBone.AddChild(leftLeg); rightLegBone.AddChild(rightLeg); leftArmBone.AddChild(leftArm); rightArmBone.AddChild(rightArm); headBone.AddChild(head); leftLegBone.IsHidden = true; rightLegBone.IsHidden = true; leftArmBone.IsHidden = true; rightArmBone.IsHidden = true; headBone.IsHidden = true; Animation zombieIdleAnimation = new Animation(new float[] { 0, MathUtil.Pi / 16f, 0, -MathUtil.Pi / 16f, 0 }, 1, int.MaxValue); zombieIdleAnimation.AddProcess(value => { headBone.SetRotationZ(value); headBone.SetRotationY(value); leftArmBone.SetRotationY(value - MathUtil.PiOverTwo); rightArmBone.SetRotationY(-value - MathUtil.PiOverTwo); }); Animation movementAnimation = new Animation(new float[] { 0, MathUtil.PiOverFour, 0, -MathUtil.PiOverFour, 0 }, 1, int.MaxValue); movementAnimation.AddProcess(value => { leftLegBone.SetRotationY(value); rightLegBone.SetRotationY(-value); }); movementAnimation.AddTransitionPaused(() => { leftLegBone.SetRotationY(0); rightLegBone.SetRotationY(0); }); body.Collision = new BoxCollision(5, 20); body.AddScript(new ZombieMovementScript(_player, movementAnimation)); body.AddComponent(new HealthComponent(100)); return(body); }