private void ActivateFloatAnimation(QAnims <float> floatQAnim) { if (floatQAnim.IsActivated) { return; } Animator.SetFloat(floatQAnim.ParamName, floatQAnim.Value); }
private void ActivateIntAnimation(QAnims <int> intQAnim) { if (intQAnim.IsActivated) { return; } Animator.SetInteger(intQAnim.ParamName, intQAnim.Value); }
private void ActivateBoolAnimation(QAnims <bool> boolQAnim) { if (boolQAnim.IsActivated) { return; } Animator.SetBool(boolQAnim.ParamName, boolQAnim.Value); }
private void ActivateTriggerAnimation(QAnims <bool> triggerQAnim) { if (triggerQAnim.IsActivated) { return; } Animator.SetTrigger(triggerQAnim.ParamName); }
private bool CheckAnimationEndCondition <T>(QAnims <T> qAnim) { if (qAnim.SkipNextUpdateCheck) { qAnim.SkipNextUpdateCheck = false; return(false); } else { bool namesMatch = Animator.GetCurrentAnimatorStateInfo(qAnim.LayerIndexOfNames).shortNameHash == qAnim.FinishAnimationNameHash; bool tagsMatch = Animator.GetCurrentAnimatorStateInfo(qAnim.LayerIndexOfNames).tagHash == qAnim.FinishAnimationTagHash; bool isInTransition = Animator.IsInTransition(qAnim.LayerIndexOfNames); return((namesMatch || tagsMatch) && !isInTransition); } }
public override void AnimateInteger(AIBrain ai, string name, int val = 0, bool isContinuous = false, bool isImmediate = false, string nextAnimationName = "", string nextAnimationTag = "", int layerIndexNames = 0) { QAnims <int> x; if (intQAnims.Find(y => y.ParamName == name) == null) { x = new QAnims <int>(name, val, Animator.GetInteger(name), isContinuous, nextAnimationName, nextAnimationTag, layerIndexNames); intQAnims.Add(x); } else { x = intQAnims.Find(y => y.ParamName == name); } if (isImmediate) { ActivateIntAnimation(x); x.IsActivated = true; x.SkipNextUpdateCheck = true; } }
// if it is not immediate it will be activated in action activate - use immediate in action update function if u need... public override void AnimateTrigger(AIBrain ai, string name, bool isContinuous = false, bool isImmediate = false, string nextAnimationName = "", string nextAnimationTag = "", int layerIndexNames = 0) { QAnims <bool> x; if (triggerQAnims.Find(y => y.ParamName == name) == null) { x = new QAnims <bool>(name, false, false, isContinuous, nextAnimationName, nextAnimationTag, layerIndexNames); triggerQAnims.Add(x); } else { x = triggerQAnims.Find(y => y.ParamName == name); } if (isImmediate) { ActivateTriggerAnimation(x); x.IsActivated = true; x.SkipNextUpdateCheck = true; } }