public static void AddCustomAnimation(string name, AnimationClip animationClip, bool looping, string _wwiseEventName = "", string _wwiseStopEvent = "", HumanBodyBones[] rootBonesToIgnore = null, HumanBodyBones[] soloBonesToIgnore = null, AnimationClip secondaryAnimation = null, bool dimWhenClose = false, bool stopWhenMove = false, bool stopWhenAttack = false) { if (BoneMapper.animClips.ContainsKey(name)) { //DebugClass.Log($"Error #1: [{name}] is already defined as a custom emote but is trying to be added. Skipping"); return; } if (rootBonesToIgnore == null) { rootBonesToIgnore = new HumanBodyBones[0]; } if (soloBonesToIgnore == null) { soloBonesToIgnore = new HumanBodyBones[0]; } CustomAnimationClip clip = new CustomAnimationClip(animationClip, looping, _wwiseEventName, _wwiseStopEvent, rootBonesToIgnore, soloBonesToIgnore, secondaryAnimation, dimWhenClose, stopWhenMove, stopWhenAttack); allClipNames.Add(name); BoneMapper.animClips.Add(name, clip); }
public void PlayAnim(string s) { a2.enabled = true; List <string> dontAnimateUs = new List <string>(); if (s != "none") { if (!animClips.ContainsKey(s)) { DebugClass.Log($"No animation bound to the name [{s}]"); return; } currentClip = animClips[s]; foreach (var item in currentClip.soloIgnoredBones) { if (a2.GetBoneTransform(item)) { dontAnimateUs.Add(a2.GetBoneTransform(item).name); } } foreach (var item in currentClip.rootIgnoredBones) { if (a2.GetBoneTransform(item)) { dontAnimateUs.Add(a2.GetBoneTransform(item).name); } foreach (var bone in a2.GetBoneTransform(item).GetComponentsInChildren <Transform>()) { dontAnimateUs.Add(bone.name); } } } for (int i = 0; i < smr2.bones.Length; i++) { try { if (smr2.bones[i].gameObject.GetComponent <ParentConstraint>() && !dontAnimateUs.Contains(smr2.bones[i].name)) { smr2.bones[i].gameObject.GetComponent <ParentConstraint>().constraintActive = true; } else if (dontAnimateUs.Contains(smr2.bones[i].name)) { smr2.bones[i].gameObject.GetComponent <ParentConstraint>().constraintActive = false; } } catch (Exception) { } } foreach (var item in stopEvents) { AkSoundEngine.PostEvent(item, gameObject); } if (s == "none") { a2.Play("none", -1, 0f); twopart = false; currentClip = null; return; } if (currentClip.wwiseEvent != "") { AkSoundEngine.PostEvent(currentClip.wwiseEvent, gameObject); } AnimatorOverrideController animController = new AnimatorOverrideController(a2.runtimeAnimatorController); if (currentClip.secondaryClip) { animController["Dab"] = currentClip.clip; animController["nobones"] = currentClip.secondaryClip; a2.runtimeAnimatorController = animController; a2.Play("PoopToLoop", -1, 0f); } else if (currentClip.looping) { animController["Floss"] = currentClip.clip; a2.runtimeAnimatorController = animController; a2.Play("Loop", -1, currentClip.syncTimer / currentClip.clip.length); } else { animController["Default Dance"] = currentClip.clip; a2.runtimeAnimatorController = animController; a2.Play("Poop", -1, currentClip.syncTimer / currentClip.clip.length); } twopart = false; }