/// <summary> /// Override this to send parameters to the character's animator. This is called once per cycle, by the Character /// class, after Early, normal and Late process(). /// </summary> public override void UpdateAnimator() { if (CurrentWeapon == null) { return; } InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.IdleAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponIdle), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.StartAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponStart), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.DelayBeforeUseAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.UseAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBeforeUse || CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse || CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.SingleUseAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponUse), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.DelayBetweenUsesAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponDelayBetweenUses), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.StopAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponStop), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.ReloadStartAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStart), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.ReloadAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReload), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, CurrentWeapon.ReloadStopAnimationParameter, (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStop), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "Attack2", (CurrentWeapon.WeaponState.CurrentState == Weapon.WeaponStates.WeaponReloadStop), _character._animatorParameters); if (_aimableWeapon != null) { InfAnimator.UpdateAnimatorFloat(_animator, CurrentWeapon.WeaponAngleAnimationParameter, _aimableWeapon.CurrentAngle, _character._animatorParameters); InfAnimator.UpdateAnimatorFloat(_animator, CurrentWeapon.WeaponAngleRelativeAnimationParameter, _aimableWeapon.CurrentAngleRelative, _character._animatorParameters); } else { InfAnimator.UpdateAnimatorFloat(_animator, CurrentWeapon.WeaponAngleAnimationParameter, 0f, _character._animatorParameters); InfAnimator.UpdateAnimatorFloat(_animator, CurrentWeapon.WeaponAngleRelativeAnimationParameter, 0f, _character._animatorParameters); } }
/// <summary> /// This is called at Update() and sets each of the animators parameters to their corresponding State values /// </summary> protected virtual void UpdateAnimators() { if ((UseDefaultMecanim) && (_animator != null)) { InfAnimator.UpdateAnimatorBool(_animator, "Grounded", _controller.State.IsGrounded, _animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "Alive", (ConditionState.CurrentState != CharacterStates.CharacterConditions.Dead), _animatorParameters); InfAnimator.UpdateAnimatorFloat(_animator, "xSpeed", _controller.Speed.x, _animatorParameters); InfAnimator.UpdateAnimatorFloat(_animator, "xAbsSpeed", Mathf.Abs(_controller.Speed.x), _animatorParameters); InfAnimator.UpdateAnimatorFloat(_animator, "ySpeed", _controller.Speed.y, _animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "CollidingLeft", _controller.State.IsCollidingLeft, _animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "CollidingRight", _controller.State.IsCollidingRight, _animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "CollidingBelow", _controller.State.IsCollidingBelow, _animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "CollidingAbove", _controller.State.IsCollidingAbove, _animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "Idle", (MovementState.CurrentState == CharacterStates.MovementStates.Idle), _animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "FacingRight", IsFacingRight, _animatorParameters); foreach (CharacterAbility ability in _characterAbilities) { if (ability.enabled && ability.AbilityInitialized) { ability.UpdateAnimator(); } } } }
/// <summary> /// At the end of each cycle, we update our animator with our various states /// </summary> public override void UpdateAnimator() { InfAnimator.UpdateAnimatorBool(_animator, "LadderClimbing", (_movement.CurrentState == CharacterStates.MovementStates.LadderClimbing), _character._animatorParameters); InfAnimator.UpdateAnimatorFloat(_animator, "LadderClimbingSpeedX", CurrentLadderClimbingSpeed.x, _character._animatorParameters); InfAnimator.UpdateAnimatorFloat(_animator, "LadderClimbingSpeedY", CurrentLadderClimbingSpeed.y, _character._animatorParameters); }
/// <summary> /// Sends the current speed and the current value of the Walking state to the animator /// </summary> public override void UpdateAnimator() { InfAnimator.UpdateAnimatorFloat(_animator, "Speed", _horizontalMovement, _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "Walking", (_movement.CurrentState == CharacterStates.MovementStates.Walking), _character._animatorParameters); InfAnimator.UpdateAnimatorBool(_animator, "Running", (_movement.CurrentState == CharacterStates.MovementStates.Running), _character._animatorParameters); }