public ActionAnimationHandler(AnimationLayerMixerPlayable mixer, ActionAnimationDefinition[] actionAnimationDefs) { if (actionAnimationDefs == null) { return; } m_mixer = mixer; foreach (var def in actionAnimationDefs) { if (def.animation == null) { continue; } if (m_actionAnimations.ContainsKey(def.action)) { continue; } ActionAnimation actionAnim = new ActionAnimation(); actionAnim.animation = AnimationClipPlayable.Create(mixer.GetGraph(), def.animation); actionAnim.animation.SetApplyFootIK(false); actionAnim.animation.SetDuration(def.animation.length); actionAnim.port = mixer.AddInput(actionAnim.animation, 0); actionAnim.restartTimeOffset = def.restartTimeOffset; mixer.SetLayerAdditive((uint)actionAnim.port, true); m_actionAnimations.Add(def.action, actionAnim); } }
protected virtual void Awake() { var animator = GetComponent <Animator>(); var renderer = GetComponent <CharacterRenderer>(); attackAnimation = new ActionAnimation(animator, renderer, "Attack", 0.5f); soundPlayer = GetComponentInChildren <CharacterSoundsPlayer>(); }
// Start is called before the first frame update void Awake() { Dead = InitiallyDead; var animator = GetComponent <Animator>(); renderer = GetComponent <CharacterRenderer>(); selection = GetComponent <UnitSelection>(); dyingAnimation = new ActionAnimation(animator, renderer, "Dying", 0.5f); soundPlayer = GetComponentInChildren <CharacterSoundsPlayer>(); movement = GetComponent <CharacterMovement>(); switchOffAbleComponents = new ComponentsSet(this, "Attack", "CharacterMovement", "ClickCatching", "UnitSelection", "Navigator"); }