// Use this for initialization void Start() { EnemyHealth = 10; nextAction = Time.time; an = GetComponent<Animation>(); an.CrossFade ("run"); }
private void LoopAnimation(string thisAnimation, Animation anim) { anim.wrapMode = WrapMode.Loop; anim.CrossFade(thisAnimation); anim[thisAnimation].time = Random.Range(0f, 3f); }
private void RollTrack(Animation track, int defaultRollTime) { if (track != null) { track.CrossFade("10107_Trap01"); SetNextRoll(track, defaultRollTime); } }
void Start() { smooth = 5.0f; scaler = 25.0f; walkingSpeed = 5.0f; velocity = Vector3.zero; anim = GetComponent<Animation> (); anim.CrossFade ("soldierIdleRelaxed"); previousValidPos = transform.position; }
/// <summary> /// Execute legacy animation. /// </summary> /// <param name="clip">Legacy Animation Clip.</param> /// <param name="fadeLength">Period of time over which animation clip will fade.</param> /// <param name="force">Legacy Animation Clip.</param> public void Animate(AnimationClip clip, float fadeLength = 0.3F, bool force = false) { if (_animation && clip != null) { if (force) { _animation.Stop(); } _animation.CrossFade(clip.name, fadeLength); } }
public AnimationState CrossFadeAnim(AnimGroup group, AnimIndex anim, float duration, PlayMode playMode) { var animState = LoadAnim(group, anim); _curAnimGroup = AnimGroup = group; _curAnim = AnimIndex = anim; _anim.CrossFade(animState.name, duration, playMode); return(animState); }
void MirrorCharacterAnimations() { if (mirrorCharacterAnim) { animation = transform.Find("Model").GetComponent<Animation>(); if (animation != null) { if (originalController == null) { originalController = original.GetComponent<Character>().controller; } animation[originalController.animationPlaying].speed = originalController.animationSpeed; animation.CrossFade(originalController.animationPlaying); } } }
static public int CrossFade__String(IntPtr l) { try { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); self.CrossFade(a1); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public static int CrossFade2_wrap(long L) { try { long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.Animation obj = get_obj(nThisPtr); string arg0 = FCLibHelper.fc_get_string_a(L, 0); obj.CrossFade(arg0); } catch (Exception e) { Debug.LogException(e); } return(0); }
public static int CrossFade_wrap(long L) { try { long nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L); UnityEngine.Animation obj = get_obj(nThisPtr); string arg0 = FCLibHelper.fc_get_string_a(L, 0); float arg1 = FCLibHelper.fc_get_float(L, 1); UnityEngine.PlayMode arg2 = (UnityEngine.PlayMode)(FCLibHelper.fc_get_int(L, 2)); obj.CrossFade(arg0, arg1, arg2); } catch (Exception e) { Debug.LogException(e); } return(0); }
static public int CrossFade(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (argc == 5) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 3, out a1); System.Single a2; checkType(l, 4, out a2); UnityEngine.PlayMode a3; checkEnum(l, 5, out a3); self.CrossFade(a1, a2, a3); pushValue(l, true); return(1); } else if (argc == 4) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 3, out a1); System.Single a2; checkType(l, 4, out a2); self.CrossFade(a1, a2); pushValue(l, true); return(1); } else if (argc == 3) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 3, out a1); self.CrossFade(a1); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int CrossFade__String__Single__PlayMode(IntPtr l) { try { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); UnityEngine.PlayMode a3; checkEnum(l, 4, out a3); self.CrossFade(a1, a2, a3); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public void PlayAnimation(UnityEngine.AnimationClip animationClip) { if (animationClip == null) { throw new ArgumentNullException("animationClip"); } if (mAnimationComponent[animationClip.name] == null) { mAnimationComponent.AddClip(animationClip, animationClip.name); } if (mAnimationComponent.gameObject.active == true) { mAnimationComponent[animationClip.name].enabled = true; mAnimationComponent[animationClip.name].weight = 1.0f; mAnimationComponent.CrossFade(animationClip.name, 0.3f, PlayMode.StopAll); } }
static int CrossFade(IntPtr L) { #if UNITY_EDITOR ToluaProfiler.AddCallRecord("UnityEngine.Animation.Register"); #endif try { int count = LuaDLL.lua_gettop(L); if (count == 2) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); string arg0 = ToLua.CheckString(L, 2); obj.CrossFade(arg0); return(0); } else if (count == 3) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); string arg0 = ToLua.CheckString(L, 2); float arg1 = (float)LuaDLL.luaL_checknumber(L, 3); obj.CrossFade(arg0, arg1); return(0); } else if (count == 4) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject(L, 1, typeof(UnityEngine.Animation)); string arg0 = ToLua.CheckString(L, 2); float arg1 = (float)LuaDLL.luaL_checknumber(L, 3); UnityEngine.PlayMode arg2 = (UnityEngine.PlayMode)ToLua.CheckObject(L, 4, typeof(UnityEngine.PlayMode)); obj.CrossFade(arg0, arg1, arg2); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.CrossFade")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static public int CrossFade(IntPtr l) { try{ int argc = LuaDLL.lua_gettop(l); if (argc == 4) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); UnityEngine.PlayMode a3; checkEnum(l, 4, out a3); self.CrossFade(a1, a2, a3); return(0); } else if (argc == 3) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); self.CrossFade(a1, a2); return(0); } else if (argc == 2) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); self.CrossFade(a1); return(0); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int CrossFade(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject <UnityEngine.Animation>(L, 1); string arg0 = ToLua.CheckString(L, 2); obj.CrossFade(arg0); return(0); } else if (count == 3) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject <UnityEngine.Animation>(L, 1); string arg0 = ToLua.CheckString(L, 2); float arg1 = (float)LuaDLL.luaL_checknumber(L, 3); obj.CrossFade(arg0, arg1); return(0); } else if (count == 4) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.CheckObject <UnityEngine.Animation>(L, 1); string arg0 = ToLua.CheckString(L, 2); float arg1 = (float)LuaDLL.luaL_checknumber(L, 3); UnityEngine.PlayMode arg2 = (UnityEngine.PlayMode)ToLua.CheckObject(L, 4, TypeTraits <UnityEngine.PlayMode> .type); obj.CrossFade(arg0, arg1, arg2); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.CrossFade")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int CrossFade(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(string))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); obj.CrossFade(arg0); return(0); } else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(string), typeof(float))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); float arg1 = (float)LuaDLL.lua_tonumber(L, 3); obj.CrossFade(arg0, arg1); return(0); } else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Animation), typeof(string), typeof(float), typeof(UnityEngine.PlayMode))) { UnityEngine.Animation obj = (UnityEngine.Animation)ToLua.ToObject(L, 1); string arg0 = ToLua.ToString(L, 2); float arg1 = (float)LuaDLL.lua_tonumber(L, 3); UnityEngine.PlayMode arg2 = (UnityEngine.PlayMode)ToLua.ToObject(L, 4); obj.CrossFade(arg0, arg1, arg2); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Animation.CrossFade")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int QPYX_CrossFade_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 2) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2); QPYX_obj_YXQP.CrossFade(QPYX_arg0_YXQP); return(0); } else if (QPYX_count_YXQP == 3) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2); float QPYX_arg1_YXQP = (float)LuaDLL.luaL_checknumber(L_YXQP, 3); QPYX_obj_YXQP.CrossFade(QPYX_arg0_YXQP, QPYX_arg1_YXQP); return(0); } else if (QPYX_count_YXQP == 4) { UnityEngine.Animation QPYX_obj_YXQP = (UnityEngine.Animation)ToLua.CheckObject(L_YXQP, 1, typeof(UnityEngine.Animation)); string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2); float QPYX_arg1_YXQP = (float)LuaDLL.luaL_checknumber(L_YXQP, 3); UnityEngine.PlayMode QPYX_arg2_YXQP = (UnityEngine.PlayMode)ToLua.CheckObject(L_YXQP, 4, typeof(UnityEngine.PlayMode)); QPYX_obj_YXQP.CrossFade(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP); return(0); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Animation.CrossFade")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
public void Start() { string audioClipName = GetParameter(0); string animationClipName = GetParameter(1); finalClipName = GetParameter(2); subject = GetSubject(3); anim = (subject == null) ? null : subject.GetComponent<Animation>(); AudioClip audioClip = (!string.IsNullOrEmpty(audioClipName)) ? (DialogueManager.LoadAsset(audioClipName) as AudioClip) : null; if ((subject == null) || (anim == null)) { if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4}) command: No Animation component found on {3}.", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, (subject != null) ? subject.name : GetParameter(2) })); } else if (audioClip == null) { if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4}) command: Clip is null.", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, subject.name })); } else if (string.IsNullOrEmpty(animationClipName)) { if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4}) command: Animation name is blank.", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, subject.name })); } else { if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4})", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, Tools.GetObjectName(subject) })); audioSource = SequencerTools.GetAudioSource(subject); if (audioSource == null) { if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: Sequencer: Voice() command: can't find or add AudioSource to {1}.", new System.Object[] { DialogueDebug.Prefix, subject.name })); } else { if (IsAudioMuted()) { if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Sequencer: Voice({1}, {2}, {3}, {4}): Audio is muted; not playing it.", new System.Object[] { DialogueDebug.Prefix, audioClipName, animationClipName, finalClipName, Tools.GetObjectName(subject) })); } else { //--- Was, prior to implementing pause: audioSource.PlayOneShot(audioClip); audioSource.clip = audioClip; audioSource.Play(); } anim.CrossFade(animationClipName); try { stopTime = DialogueTime.time + Mathf.Max(0.1f, anim[animationClipName].length - 0.3f); if (audioClip.length > anim[animationClipName].length) stopTime = DialogueTime.time + audioClip.length; } catch (System.Exception) { stopTime = 0; } } } }
public void SpecialAttack(Animation _anim, GameObject _target, float _dmg) { _anim.CrossFade("Special"); _target.GetComponent<PlayerObject>().ApplyDamage(_dmg * 2); useSpecial = false; this.hasAttacked = true; }
// Use this for initialization public virtual void Start() { velocity = new Vector3 (); acceleration = new Vector3 (); accMagDefault = 50.0f; speedMaxDefault = 20.0f; walkingSpeed = 15.0f; epsilon = 2.0f; searchRadius = 100.0f; rayDistDefault = 20.0f; rayDist = rayDistDefault; closeRayDistDefault = 7.0f; closeRayDist = closeRayDistDefault; charWidth = 5.0f; smooth = 5.0f; obstacleWeight = 3.0f; charWeight = 1.0f; accMag = accMagDefault; speedMax = speedMaxDefault; anim = GetComponent<Animation> (); anim.CrossFade ("idle"); }
public static int metcrossfadetransitionanimation(Transform varpcharacter, string varpdestinationanimname, float varptransitiontime, Transform varpcontroller = null, string varpstateanimationname = "", bool varpgokinematic = true, string varpnewanimname = "transition", Animation varpanimationsystem = null, SkinnedMeshRenderer varprenderer = null, clsurganimationstatesmanager varpstatesmanager = null) { if (varpcharacter == null) { return -1; } if (varptransitiontime == 0f) { return -2; } if (varpanimationsystem == null) { varpanimationsystem = varpcharacter.root.GetComponentInChildren<Animation>(); if (varpanimationsystem == null) { return -3; } varpanimationsystem.Stop(); } if (varprenderer == null) { varprenderer = varpcharacter.root.GetComponentInChildren<SkinnedMeshRenderer>(); if (varprenderer == null) { return -4; } } if (varpgokinematic) { clsurgutils.metgodriven(varpcharacter, true); } Vector3 localPosition = default(Vector3); if (varpcontroller != null) { Vector3 position = varpcharacter.position; varpcontroller.position = position; varpcharacter.localPosition = localPosition; } AnimationClip animationClip = clsurgutils.metcreatetransitionanimation(varpcharacter, varpdestinationanimname, varptransitiontime, varpnewanimname, ref localPosition, varpstatesmanager, false); if (animationClip != null) { varpanimationsystem.Stop(); AnimationState animationState = varpanimationsystem[varpdestinationanimname]; if (animationState != null && animationState.name != varpdestinationanimname) { varpanimationsystem.RemoveClip(varpnewanimname); } varpanimationsystem.AddClip(animationClip, varpnewanimname); if (varpstateanimationname != string.Empty) { varpanimationsystem[varpnewanimname].wrapMode = WrapMode.Once; varpanimationsystem.CrossFade(varpnewanimname); varpanimationsystem.CrossFadeQueued(varpstateanimationname); } else { varpanimationsystem.CrossFade(varpnewanimname); } return 1; } Debug.LogError("Could not create transition"); return -5; }
public override void Seek(float time) { base.Seek(time); if (_LayerKeys == null) { _LayerKeys = new CrossFadeAnimationKey[10]; // maximum 10 layer support } for (int i = 0; i < _LayerKeys.Length; i++) { _LayerKeys[i] = null; } if (_Animation != null && _Animation.enabled) { ResetAnimations();// reset weight of all used animations if (Keys != null && Keys.Length > 0 && Index >= 0) { for (int i = 0; i <= Index; i++) { CrossFadeAnimationKey cfak = Keys[i] as CrossFadeAnimationKey; if (cfak != null) { if (!string.IsNullOrEmpty(cfak._Animation)) { AnimationState newState = _Animation[cfak._Animation]; if (newState != null) { float stateWeight = 1.0f; if (cfak._Layer < _LayerKeys.Length) { if (_LayerKeys[cfak._Layer] != null) { AnimationState preState = _Animation[_LayerKeys[cfak._Layer]._Animation]; if (preState != null) { if (time >= cfak.FireTime + cfak.FadeLenght) { preState.weight = 0.0f; preState.time = 0.0f; } else if (time >= cfak.FireTime) { stateWeight = (time - cfak.FireTime) / cfak.FadeLenght; preState.weight = 1.0f - stateWeight; preState.time = time - _LayerKeys[cfak._Layer].FireTime; } } } _LayerKeys[cfak._Layer] = cfak; } cfak.ApplyStateParameters(newState); _Animation.CrossFade(newState.name, 0, cfak.Mode); newState.weight = stateWeight; newState.time = time - cfak.FireTime; } } } } } else if (!string.IsNullOrEmpty(_DefaultAnimation)) { AnimationState state = _Animation[_DefaultAnimation]; if (state != null) { _Animation.CrossFade(state.name, 0, PlayMode.StopAll); state.time = time; state.weight = 1.0f; } } _Animation.Sample(); // this is a stupid code to make unity update animation completely in SceneView if (!Application.isPlaying) { _Animation.enabled = false; _Animation.enabled = true; } } }
public void Init(GameObject target) { if (!HasInitiated) { HasInitiated = true; player = target; animations = player.GetComponent<Animation>(); animations.CrossFade(stateAnimation[animationState]); player.SetActive(false); } }
//methods // Use this for initialization public virtual void Start() { anim = GetComponent<Animation>(); velocity = new Vector3 (); nextPosition = new Vector3 (); //position where char wants to move to next acceleration = new Vector3 (); targetAccel = new Vector3 (); accMag = 50.0f; maxRadsDelta = Mathf.Deg2Rad * 20.0f; maxMagDelta = 100.0f; maxSpeed = 20.0f; behaviorWeight = 1.0f; smooth = 5.0f; walkingSpeed = 20.0f; randomRad = 0.0f; charWidth = 5.0f; rayDist = 30.0f; rayDistMax = rayDist; originalMaxSpeed = maxSpeed; rayDistClose = 5.0f; anim.CrossFade ("idle"); count = 0; }
/// <summary> /// 淡入淡出播放 /// </summary> /// <param name="animation"></param> public void Play(string animation) { Debug.Log("11"); m_Animation.CrossFade(animation, 0.2f, PlayMode.StopAll); }
public void SwitchSkin(GameObject skin) { Vector3 current_pos = player.transform.position; Vector3 current_rot = player.transform.eulerAngles; Vector3 current_scale = player.transform.localScale; player = skin; player.transform.position = current_pos; player.transform.eulerAngles = current_rot; player.transform.localScale = current_scale; animations = player.GetComponent<Animation>(); animations.CrossFade(stateAnimation[animationState]); ShouldSwitch = false; }
static public int CrossFade(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (argc == 2) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); self.CrossFade(a1); pushValue(l, true); return(1); } else if (argc == 3) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); self.CrossFade(a1, a2); pushValue(l, true); return(1); } else if (argc == 4) { UnityEngine.Animation self = (UnityEngine.Animation)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Single a2; checkType(l, 3, out a2); UnityEngine.PlayMode a3; a3 = (UnityEngine.PlayMode)LuaDLL.luaL_checkinteger(l, 4); self.CrossFade(a1, a2, a3); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function CrossFade to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
private void AnimationSetup() { anim_ = GetComponent("Animation") as Animation; // loop in sync anim_["Walk"].layer = 1; anim_["Run"].layer = 1; anim_.SyncLayer(1); // speed up & play once anim_["RunJump"].wrapMode = WrapMode.ClampForever; anim_["RunJump"].speed = 2; anim_["Ladder_Up"].wrapMode = WrapMode.ClampForever; anim_["Ladder_Up"].speed = 2; anim_["Ladder_Down"].wrapMode = WrapMode.ClampForever; anim_["Ladder_Down"].speed = 2; if ( isADAPTMan_ ) { anim_["Turn180"].wrapMode = WrapMode.ClampForever; anim_["Turn180"].speed = ladderSpeed_; anim_["Turn180-down"].wrapMode = WrapMode.ClampForever; anim_["Turn180-down"].speed = ladderSpeed_; anim_["Walk_Up"].wrapMode = WrapMode.ClampForever; anim_["Walk_Up"].speed = ladderSpeed_; } anim_.CrossFade("Idle", blendTime, PlayMode.StopAll); }
private bool PlayAnimation(Animation animation, string name) { bool b = false; if(animation != null && name != "" && animation[name] != null) { if(this.show) animation[name].layer = this.min; if(this.playOptions[this.number] == "Play") { animation.Play(name, this.playMode); } else if(this.playOptions[this.number] == "CrossFade") { animation.CrossFade(name, this.time, this.playMode); } else if(this.playOptions[this.number] == "Blend") { animation.Blend(name, this.speed, this.time); } else if(this.playOptions[this.number] == "PlayQueued") { animation.PlayQueued(name, this.queueMode, this.playMode); } else if(this.playOptions[this.number] == "CrossFadeQueued") { animation.CrossFadeQueued(name, this.time, this.queueMode, this.playMode); } b = true; } return b; }
public static void PlayAnimClip (Animation _animation, int layer, AnimationClip clip, AnimationBlendMode blendMode, WrapMode wrapMode, float fadeTime, Transform mixingBone, bool reverse) { // Initialises and crossfades a clip if (clip != null) { AddAnimClip (_animation, layer, clip, blendMode, wrapMode, mixingBone); if (reverse) { _animation[clip.name].speed *= -1f; } _animation.CrossFade (clip.name, fadeTime); CleanUnusedClips (_animation); } }
// Use this for initialization public void Starta(GameObject plane, float nodeSize, Vector3 sP) { fixedDeadCollider = false; poi = Vector3.zero; health = 100.0f; seesPlayer = false; lastSeen = Vector3.zero; lastSeenForward = Vector3.zero; seesDeadPeople = false; hearsSomething = false; disturbed = false; isDead = false; addToDeadSet = false; takingCover = false; coverSpot = Vector3.zero; reachedCover = false; sniperPosKnown = false; sniperPos = sP; isGoaling = false; isGoingToSeenPlayerPos = false; isGoingToCover = false; dirSearchCountDown = 0.0f; reachGoal = GetComponent<ReachGoal> (); wander = GetComponent<Wander> (); standstill = GetComponent<StandStill> (); patrol = GetComponent<Patrol> (); gc = player.GetComponent<GoalControl> (); reachGoal.plane = plane; reachGoal.nodeSize = nodeSize; reachGoal.goalPos = poi; reachGoal.sniperPos = sniperPos; reachGoal.Starta (); wander.Starta (); patrol.Starta (); standstill.Starta (); takeCover = new TakeCover (reachGoal.state.sGrid.hiddenSpaceCost, reachGoal.state.sGrid.grid, reachGoal.state.sGrid.spaceCostScalars); anim = GetComponent<Animation> (); anim.CrossFade (idle); walkingSpeed = 10.0f; gunShot = this.GetComponents<AudioSource> ()[0]; lr = this.GetComponentInParent<LineRenderer> (); seenTime = 0f; alertLevel = 0; maxAlertLevel = 3; needsToRaiseAlertLevel = false; isReloading = false; isShooting = false; ammoCount = 0; // Debug.Log (transform.name); }
public void Attack(Animation _anim , GameObject _target , float _dmg) { _anim.CrossFade("Attack"); _target.GetComponent<PlayerObject>().ApplyDamage(_dmg); this.hasAttacked = true; }
private void AnimationSetup() { anim = GetComponent<Animation>(); // 把walk和run动画放到同一层,然后同步他们的速度。 anim["Walk"].layer = 1; anim["Run"].layer = 1; anim.SyncLayer(1); //设置“跳跃”,“爬楼梯”,“下楼梯”的动画模式和速度 anim["RunJump"].wrapMode = WrapMode.ClampForever; anim["RunJump"].speed = 2; anim["Ladder Up"].wrapMode = WrapMode.ClampForever; anim["Ladder Up"].speed = 2; anim["Ladder Down"].wrapMode = WrapMode.ClampForever; anim["Ladder Down"].speed = 2; //初始化动画状态为Idle anim.CrossFade("Idle", 0.1f, PlayMode.StopAll); }
public void realPlay( Animation am ) { am.CrossFade( _aType ); }
void Start() { radius = 2.0f; smooth = 5.0f; scaler = 20.0f; walkingSpeed = 5.0f; velocity = Vector3.zero; anim = GetComponent<Animation> (); anim.CrossFade (idle); previousValidPos = transform.position; soldierLayer = 1 << (LayerMask.NameToLayer("Soldier")); obstacleLayer = 1 << (LayerMask.NameToLayer("Obstacles")); health = 20; healthTex = new Texture2D(1, 1); healthTex.SetPixel(0,0,Color.green); healthTex.Apply(); }
/** * <summary>Initialises and plays a legacy AnimationClip on an Animation component.</summary> * <param name = "_animation">The Animation component</param> * <param name = "layer">The layer to play the animation on</param> * <param name = "clip">The AnimatonClip to play</param> * <param name = "blendMode">The animation's AnimationBlendMode</param> * <param name = "wrapMode">The animation's WrapMode</param> * <param name = "fadeTime">The transition time to the new animation</param> * <param name = "mixingBone">The transform to set as the animation's mixing transform</param> * <param name = "reverse">True if the animation should be reversed</param> */ public static void PlayAnimClip(Animation _animation, int layer, AnimationClip clip, AnimationBlendMode blendMode = AnimationBlendMode.Blend, WrapMode wrapMode = WrapMode.ClampForever, float fadeTime = 0f, Transform mixingBone = null, bool reverse = false) { if (clip != null) { AddAnimClip (_animation, layer, clip, blendMode, wrapMode, mixingBone); if (reverse) { _animation[clip.name].speed *= -1f; } _animation.CrossFade (clip.name, fadeTime); CleanUnusedClips (_animation); } }
private IEnumerator QueueIdle(Animation source) { while (source.IsPlaying(_ClipName)) yield return new WaitForFixedUpdate(); source.CrossFade(AnimationResources.Idle); }
// Activate a Legacy animation private void Activate(Animation animation) { if (animationState == empty) return; if (resetNormalizedTime) animation[animationState].normalizedTime = 0f; animation[animationState].layer = layer; animation.CrossFade(animationState, crossfadeTime); }
// Use this for initialization public void Starta(GameObject plane, GameObject swamps, float nodeSize) { fixedDeadCollider = false; poi = Vector3.zero; health = 100.0f; seesPlayer = false; seesDeadPeople = false; hearsSomething = false; disturbed = false; reachGoal = GetComponent<ReachGoal> (); wander = GetComponent<Wander> (); standstill = GetComponent<StandStill> (); patrol = GetComponent<Patrol> (); gc = player.GetComponent<GoalControl> (); reachGoal.plane = plane; reachGoal.swamps = swamps; reachGoal.nodeSize = nodeSize; reachGoal.goalPos = poi; reachGoal.Starta (); wander.Starta (); patrol.Starta (); standstill.Starta (); anim = GetComponent<Animation> (); anim.CrossFade (idle); walkingSpeed = 10.0f; gunShot = this.GetComponents<AudioSource> ()[0]; lr = this.GetComponentInParent<LineRenderer> (); seenTime = 0f; // Debug.Log (transform.name); }