protected void OnAnimatorMove() { if (!CacheAnimator) { return; } if (useRootMotionWhileNotMoving && !CacheEntity.MovementState.HasFlag(MovementState.Forward) && !CacheEntity.MovementState.HasFlag(MovementState.Backward) && !CacheEntity.MovementState.HasFlag(MovementState.Left) && !CacheEntity.MovementState.HasFlag(MovementState.Right) && !CacheEntity.MovementState.HasFlag(MovementState.IsJump)) { // No movement, apply root motion position / rotation CacheAnimator.ApplyBuiltinRootMotion(); return; } if (CacheEntity.MovementState.HasFlag(MovementState.IsGrounded) && useRootMotionForMovement) { CacheAnimator.ApplyBuiltinRootMotion(); } if (!CacheEntity.MovementState.HasFlag(MovementState.IsGrounded) && useRootMotionForAirMovement) { CacheAnimator.ApplyBuiltinRootMotion(); } }
public async Task PlayActionAnimation_Animator(int actionId, AnimActionType animActionType, float playSpeedMultiplier) { // If animator is not null, play the action animation ActionAnimation actionAnimation; AnimationClip clip; float triggerDuration; float extraDuration; AudioClip audioClip; if (GameInstance.ActionAnimations.TryGetValue(actionId, out actionAnimation) && actionAnimation.GetData(this, out clip, out triggerDuration, out extraDuration, out audioClip)) { CacheAnimator.SetBool(ANIM_DO_ACTION, false); CacheAnimatorController[ANIM_STATE_ACTION_CLIP] = clip; if (audioClip != null) { AudioSource.PlayClipAtPoint(audioClip, CacheTransform.position, AudioManager.Singleton == null ? 1f : AudioManager.Singleton.sfxVolumeSetting.Level); } CacheAnimator.SetFloat(ANIM_ACTION_CLIP_MULTIPLIER, playSpeedMultiplier); CacheAnimator.SetBool(ANIM_DO_ACTION, true); // Waits by current transition + clip duration before end animation int waitDelay = (int)(1000 * (CacheAnimator.GetAnimatorTransitionInfo(0).duration + (clip.length / playSpeedMultiplier))); await Task.Delay(waitDelay); CacheAnimator.SetBool(ANIM_DO_ACTION, false); // Waits by current transition + extra duration before end playing animation state waitDelay = (int)(1000 * (CacheAnimator.GetAnimatorTransitionInfo(0).duration + (extraDuration / playSpeedMultiplier))); await Task.Delay(waitDelay); } }
public override void PlayJumpAnimation() { if (animatorType == AnimatorType.LegacyAnimtion) { CrossFadeLegacyAnimation(legacyAnimationData.jumpClip, legacyAnimationData.jumpClipFadeLength); return; } CacheAnimator.ResetTrigger(ANIM_JUMP); CacheAnimator.SetTrigger(ANIM_JUMP); }
public override void PlayHurtAnimation() { if (animatorType == AnimatorType.LegacyAnimtion) { CrossFadeLegacyAnimation(legacyAnimationData.hurtClip, legacyAnimationData.hurtClipFadeLength); return; } CacheAnimator.ResetTrigger(ANIM_HURT); CacheAnimator.SetTrigger(ANIM_HURT); }
public void PlayHurtAnimation() { switch (animatorType) { case AnimatorType.Animator: CacheAnimator.ResetTrigger(ANIM_HURT); CacheAnimator.SetTrigger(ANIM_HURT); break; case AnimatorType.LegacyAnimtion: CrossFadeLegacyAnimation(legacyAnimationData.hurtClip, legacyAnimationData.hurtClipFadeLength); break; } }
private void UpdateAnimation_Animator(bool isDead, Vector3 moveVelocity, float playMoveSpeedMultiplier) { if (!CacheAnimator.gameObject.activeInHierarchy) { return; } if (isDead && CacheAnimator.GetBool(ANIM_DO_ACTION)) { // Force set to none action when dead CacheAnimator.SetBool(ANIM_DO_ACTION, false); } CacheAnimator.SetFloat(ANIM_MOVE_SPEED, isDead ? 0 : new Vector3(moveVelocity.x, 0, moveVelocity.z).magnitude); CacheAnimator.SetFloat(ANIM_MOVE_CLIP_MULTIPLIER, playMoveSpeedMultiplier); CacheAnimator.SetFloat(ANIM_Y_SPEED, moveVelocity.y); CacheAnimator.SetBool(ANIM_IS_DEAD, isDead); }
private IEnumerator PlayActionAnimation_Animator(AnimActionType animActionType, int dataId, int index, float playSpeedMultiplier) { // If animator is not null, play the action animation tempActionAnimation = GetActionAnimation(animActionType, dataId, index); if (tempActionAnimation != null && tempActionAnimation.clip != null) { CacheAnimator.SetBool(ANIM_DO_ACTION, false); CacheAnimatorController[ANIM_STATE_ACTION_CLIP] = tempActionAnimation.clip; var audioClip = tempActionAnimation.GetRandomAudioClip(); if (audioClip != null) { AudioSource.PlayClipAtPoint(audioClip, CacheTransform.position, AudioManager.Singleton == null ? 1f : AudioManager.Singleton.sfxVolumeSetting.Level); } CacheAnimator.SetFloat(ANIM_ACTION_CLIP_MULTIPLIER, playSpeedMultiplier); CacheAnimator.SetBool(ANIM_DO_ACTION, true); // Waits by current transition + clip duration before end animation yield return(new WaitForSecondsRealtime(CacheAnimator.GetAnimatorTransitionInfo(0).duration + (tempActionAnimation.GetClipLength() / playSpeedMultiplier))); CacheAnimator.SetBool(ANIM_DO_ACTION, false); // Waits by current transition + extra duration before end playing animation state yield return(new WaitForSecondsRealtime(CacheAnimator.GetAnimatorTransitionInfo(0).duration + (tempActionAnimation.GetExtraDuration() / playSpeedMultiplier))); } }
public void PlayPlacedAnimation() { CurrentState = State.Idle; CacheAnimator.SetTrigger(placedTriggerName); }