Does name match the name of the active state in the statemachine?
// Update is called once per frame void Update() { tempo+=Time.deltaTime; if(animator) { animaState = animator.GetCurrentAnimatorStateInfo(0); if(animaState.IsName("padrao")){ if(tempo>TEMPO_DE_PISCAR ) { piscarAgora(); } }else if(animaState.IsName("cair")){ material.mainTextureOffset = new Vector3(3*deslocamento,0); }else if(animaState.IsName("dano1")){ tempo = TEMPO_DE_PISCAR; piscarAgora(); }else material.mainTextureOffset = new Vector3(0,0); }else { animator = GetComponent<Animator>(); if(animator) animaState = animator.GetCurrentAnimatorStateInfo(0); } }
public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateUpdate(animator, stateInfo, layerIndex); if (Input.GetKeyDown(KeyCode.K)) { if (stateInfo.IsName("PowerAttack.powerattack_1") && stateInfo.normalizedTime > 0.35f) { animator.CrossFade("powerattack_2", 0); } else if (stateInfo.IsName("PowerAttack.powerattack_2") && stateInfo.normalizedTime > 0.35f) { animator.CrossFade("powerattack_3", 0); } else if (stateInfo.IsName("PowerAttack.powerattack_3") && stateInfo.normalizedTime > 0.35f) { animator.CrossFade("powerattack_4", 0); } else if (stateInfo.IsName("PowerAttack.powerattack_4") && stateInfo.normalizedTime > 0.35f) { animator.CrossFade("powerattack_5", 0); } } }
void Update () { currentBaseState = anim.GetCurrentAnimatorStateInfo(0); currentShieldState = anim.GetCurrentAnimatorStateInfo(1); // Check if size change has been activated by the user if (character.sizeChangeTransition) { ActivateSizeChangeAura(); } else if (!character.sizeChangeTransition) { DeativateSizeChangeAura(); } // Check if character is holding shield if (currentShieldState.IsName("HoldShield") || currentBaseState.IsName("Dash")) { ActivateShieldWave(); } else if (!currentShieldState.IsName("HoldShield") || !currentBaseState.IsName("Dash")) { DeactivateShieldWave(); } // Check if character is dashing if (currentBaseState.IsName("Dash")) { ActivateDashEffect(); } }
// Update is called once per frame void Update() { time += Time.deltaTime; info = ani.GetCurrentAnimatorStateInfo(0); if (audio.isPlaying == false&&motionflag == false && time > 3.0f) { if (Life > 20) { audio.clip = okok; audio.Play(); ani.SetTrigger("Win"); motionflag = true; } else { audio.clip = nooo; audio.Play(); ani.SetTrigger("Lose"); motionflag = true; } } if (info.IsName("WIN00") || info.IsName("LOSE00")) { if (info.normalizedTime > 1.0f&&byeflag == false && time > 5.0f) { ani.SetTrigger("bye"); audio.clip = bye; audio.Play(); byeflag = true; } } }
// Update is called once per frame void Update () { //Debug.Log(anim.GetCurrentAnimatorStateInfo(0).tagHash.ToString()); asi = anim.GetCurrentAnimatorStateInfo (0); if (asi.IsName ("Still Scenes")) { if(!a1HasPlayed){ audSource.PlayOneShot (a1,2f); a1HasPlayed = true; } }else if (asi.IsName ("Still Scene 2")) { if(!a2HasPlayed){ audSource.PlayOneShot (a2,1f); a2HasPlayed = true; } }else if (asi.IsName ("Still Scene 3")) { if(!a3HasPlayed){ audSource.PlayOneShot (a3,1f); a3HasPlayed = true; } }else if (asi.IsName ("Cutscene Still 4")) { if(!a4HasPlayed){ audSource.PlayOneShot (a4,1f); a4HasPlayed = true; } } if ( a4HasPlayed && !audSource.isPlaying ) SceneManager.LoadScene ( "Instructions" ); }
public override void OnIdle() { animatorController.setRuning(false); if (inAttack) { // 战斗待机 } else { // 处于Base Layer // 普通待机 baseLayerStateInfo = animator.GetCurrentAnimatorStateInfo(0); if (baseLayerStateInfo.IsName("Stand") && baseLayerStateInfo.normalizedTime > 0.9) { //this.animator.SetInteger("idleType", 1); animatorController.setIdleType(1); } else if (baseLayerStateInfo.IsName("IDLE1") && baseLayerStateInfo.normalizedTime > 0.9) { //this.animator.SetInteger("idleType", 0); animatorController.setIdleType(0); } } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (stateInfo.IsName ("noop") || stateInfo.IsName ("blackout")) { fading = false; } else { fading = true; } animator.SetBool ("fading",fading); }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (stateInfo.IsName("rotToFaceIdle") == true){ GameObject.Find("Root").GetComponent<AnimLineControl>().RunSostav(); } if (stateInfo.IsName("idleUpCan") == true){ GameObject.Find("Root").GetComponent<AnimLineControl>().CanUpped(); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (stateInfo.IsName ("On")) { } if (stateInfo.IsName ("Off")) { } }
void PlayerRayController() { myASI = PlayerAnimator.GetCurrentAnimatorStateInfo(0); Vector3 posPlayer; Vector3 posPlayerDown; posPlayer = PlayerRay.transform.position; posPlayer.y += 1.5f; posPlayerDown = posPlayer; RayPlayer = new Ray (posPlayer, PlayerRay.forward); PlayerRayDown = new Ray(posPlayerDown, -PlayerRay.up); Debug.DrawRay(posPlayer, PlayerRay.forward * 2, Color.red); Debug.DrawRay(posPlayerDown, -PlayerRay.up * 2, Color.green); if (bIsGrounded && myASI.IsName("Locomotion") && !myASI.IsName("JumpUp")) { if (Physics.Raycast(RayPlayer, out hitInfo, 1.5f)) { Debug.Log("Choque para subir con : " + hitInfo.transform.tag); if (hitInfo.transform.tag.Equals("Barda") && bIsGrounded) { bIsGrounded = false; PlayerAnimator.SetTrigger("JumpToWall"); } } } else if (!bIsGrounded && !myASI.IsName("JumpDownRoll") && !myASI.IsName("JumpUp") && !myASI.IsName("Locomotion")) { if (!Physics.Raycast(PlayerRayDown, out hitInfo, 1.5f)) { PlayerAnimator.SetTrigger("JumpDown"); bIsGrounded = true; } } /// Podemos manipular los huesos para la animacion, sólo en modelos humanoides /// y sólo para las manos y pies, en el resto de las partes del cuerpo no funcionan. /// ///Modificamos el tamaño del collider dependiendo del estado de la aninmacion if (myASI.IsName("Dive")) PlayerCollider.height = PlayerAnimator.GetFloat("ScaleOffsetCapsule"); else PlayerCollider.height = startHeightCollider; }
void UpdateAnimatorStates() { animatorState = m_animator.GetCurrentAnimatorStateInfo(0); if(animatorState.IsName("Base Layer.idle")) { if(m_animator.GetInteger("anmvlue")==0) { int radom=Random.Range(1,11); if(radomValue != radom){ radomValue=radom; m_animator.SetInteger("anmvlue",radomValue); } } } else if(m_animator.GetInteger("anmvlue")!=0) { if(m_animator.GetInteger("anmvlue")==10){ Voices[8].Play(); } else{ Voices[((radomValue-1)%8)].Play(); } m_animator.SetInteger("anmvlue",0); } }
// Update is called once per frame void Update () { if (Grounded && playEff) { playEff = false; if (GroundEff != null) StartCoroutine (endEff (0.85f)); } stateInfo = anim.GetCurrentAnimatorStateInfo (0); if (player != null && stateInfo.IsName ("idle")) { if (player.position.x > gameObject.transform.position.x && !facingRight) { // ... flip the player.翻轉人物(向右)讓facingRight = true Flip (); facingRight = true; }else if (player.position.x < gameObject.transform.position.x && facingRight) { // ... flip the player.翻轉人物使其向左 讓facingRight = fales Flip (); facingRight = false; } } if (needAtk && CanAtk) { anim.SetTrigger("Atk"); atkCooldown = Random.Range(3,atkRate); } //anim.SetBool ("riceGround", Grounded); if (atkCooldown > 0) { atkCooldown -= Time.deltaTime; } }
void OnStateExit(AnimatorStateInfo info) { if (info.IsName(ExitAnimationName)) { shouldRecycle = true; } }
/// <summary> /// Method called by unity when a state is entered /// </summary> /// <param name="animator">the animator where the script is called</param> /// <param name="stateInfo">state info of the new state</param> /// <param name="layerIndex">the layer of the state change</param> public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (stateInfo.IsName("Menu_Delete")) { Destroy(animator.transform.parent.gameObject); } }
// Update is called once per frame void Update() { if(PlayerAnimator == null) PlayerAnimator = GetComponent<Animator>(); ///Obtenemos el estado actual de la animacion myASI = PlayerAnimator.GetCurrentAnimatorStateInfo(0); ///Como la tecla no tiene sensibilidad me manda 1 directamente por lo que /// no se nota la animación de Walk y parece que pasa directo a Run /// Con un Joystic se soluciona ///Caminamos si presionamos hacia arriba PlayerAnimator.SetFloat("WalkForwardSpeed", Input.GetAxis("Vertical")); ///Caminamos a la Izq o Der PlayerAnimator.SetFloat("WalkDirection", Input.GetAxis("Horizontal")); ///Preguntamos si estamos dentro de la maquina de Locomotion /// Asi evitamos que haga otro comportamiento en cualquier otra animacion /// en este caso evitamos que salte si no esta corriendo if(myASI.IsName("Locomotion")) if (Input.GetKeyDown(KeyCode.Space)) PlayerAnimator.SetTrigger("Jump"); ///Saludo aplicado con mascaras /// las máscaras sirven para desasociar partes del modelo y hacer que ciertas /// partes haagan otras animaciones. /// Como correr dos máquinas de estado al mismo tiempo. /// Si por ejemplo la animacion de disparo se realiza con el avatar completamente estático /// y quiero disparar caminando, en vez de hacer una animacion nueva de Diaparo/camino /// lo que hago es hacer máscaras, de esa forma la parte superior del torso realiza la animacion de /// disparo y l aparte inferior realiza la animacion de caminado. /// De esa forma no tengo que hacer animaciones especificas para cada estado. if (Input.GetKeyDown(KeyCode.Q)) PlayerAnimator.SetTrigger("Wave"); }
void Update() { state = animator.GetCurrentAnimatorStateInfo(0); if (!state.IsName("Move")) { nav.enabled = false; obstacle.enabled = true; moveTime = 0; animator.SetFloat("MovedTime", moveTime); return; } if (!characterController.isGrounded) { characterController.Move(Physics.gravity * Time.deltaTime * 5); } if (enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0) { nav.enabled = true; obstacle.enabled = false; nav.SetDestination(player.transform.position); } else { nav.enabled = false; obstacle.enabled = true; } moveTime += Time.deltaTime; animator.SetFloat("MovedTime", moveTime); }
void Update() { _startN = 0.0f; _endN = 0.0f; _animationState = mAnimator.GetCurrentAnimatorStateInfo (0); SwoonNode snode = System.Array.Find (_animations, xx => _animationState.IsName (xx.clipname)); if (snode != null) { _time = _animationState.normalizedTime - Mathf.Floor(_animationState.normalizedTime); float frames = (int)(_animationState.length*30); _startN = snode.start / frames; _endN = snode.end / frames; if (_time >= _startN && _time < _endN) { _trails.ForEach(x=>x.Emit = true); } else { _trails.ForEach(x=>x.Emit = false); } } else { _time = 0f; //_prevTime = _time; //_prevAnimTime = 0f; } }
public void TakeDamage(int amount, Vector3 hitPoint, int attackType, Vector3 hurtPostion) { state = animator.GetCurrentAnimatorStateInfo(0); if (isDead || state.IsName("hit03")) { return; } Vector3 targetDirection = MathUtils.XZVector(hurtPostion) - MathUtils.XZVector(transform.position); Quaternion r = Quaternion.LookRotation(targetDirection); transform.rotation = r; enemyAudio.Play(); iTween.ShakePosition(Camera.main.gameObject, iTween.Hash("x", 0.1f * attackType, "time", cameraShakeTime * attackType)); currentHealth -= amount; if (currentHealth <= 0) { Death(); } else { animator.SetTrigger("HurtType_" + attackType); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if(stateInfo.IsName("idleUp") == true){ Debug.Log("UPPPPP"); GameObject.Find("ImageTarget").GetComponent<PanelsViewer>().End(); } }
public void CheckReloadState(AnimatorStateInfo info) { if (reloadAllowed && currentWeaponState.IsName("Reloading") && info.IsName("New State")) { TP_Controller.Instance.CompleteWeaponReload(); reloadAllowed = false; } }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!GameManager.Instance.charState.IsIdle() && stateInfo.IsName("Idle")) { //Debug.Log("In Idle"); GameManager.Instance.charState.SetState(RomanCharState.State.Idle); } }
// OnStateEnter is called before OnStateEnter is called on any state inside this state machine //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) //{ //} // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { // //} // OnStateExit is called before OnStateExit is called on any state inside this state machine public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (stateInfo.IsName("Death")) { //call the destroy Destroy(GameObject.Find("pf_Character"), 0.0f); } }
public override TaskStatus OnUpdate() { stateinfo = animator.GetCurrentAnimatorStateInfo(0); if (stateinfo.IsName ("Base Layer."+animName) && stateinfo.normalizedTime >= 0.99f) { return TaskStatus.Success; } return TaskStatus.Running; }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { foreach(SlidingDoorListener li in listeners) { if (stateInfo.IsName("Opening")) { li.DoorOpening(); } else if (stateInfo.IsName("Open")) { li.DoorOpened(); } else if (stateInfo.IsName("Closing")) { li.DoorClosing(); } else if (stateInfo.IsName("Closed")) { li.DoorClosed(); } } }
public override TaskStatus OnUpdate() { stateinfo = animator.GetCurrentAnimatorStateInfo(0); if (stateinfo.IsName ("Base Layer.dead") && stateinfo.normalizedTime >= 0.99f) { gameObject.SetActive (false); return TaskStatus.Success; } return TaskStatus.Running; }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (score == null) score = GameObject.FindGameObjectWithTag("Score"); if (stateInfo.IsName("Attack")) { score.GetComponent<Text>().GetComponent<scoreControl>().updateScore(10, "Minus"); } }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { // //} // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { // //} // OnStateExit is called when a transition ends and the state machine finishes evaluating this state public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if(stateInfo.IsName("LongGunPullOut")) { animator.GetComponent<CharacterReference>().ParentCharacter.MyEventHandler.TriggerOnLongGunPullOutFinish(); } else if(stateInfo.IsName("PistolPullOut")) { animator.GetComponent<CharacterReference>().ParentCharacter.MyEventHandler.TriggerOnPistolPullOutFinish(); } else if(stateInfo.IsName("LongGunPutAway")) { animator.GetComponent<CharacterReference>().ParentCharacter.MyEventHandler.TriggerOnLongGunPutAwayFinish(); } else if(stateInfo.IsName("PistolPutAway")) { animator.GetComponent<CharacterReference>().ParentCharacter.MyEventHandler.TriggerOnPistolPutAwayFinish(); } }
//Play an animation, making sure it's not already being played. public void PlayAnimation(string animationName) { ResetAnimator(); animatorState = objectAnimator.GetCurrentAnimatorStateInfo(0); if (animatorState.IsName(animationName) == false) objectAnimator.Play(animationName); currentAnimName = animationName; }
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { // //} // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { // //} // OnStateExit is called when a transition ends and the state machine finishes evaluating this state public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { DeathRogumer deathRogumer = GameObject.FindObjectOfType<DeathRogumer> (); if(!deathRogumer.deployingVile) { if(stateInfo.IsName("enemy-death rogumer-lift-deploy")) { deathRogumer.DeployRoadAttacker (); } } }
void Update() { m_CurStateInfo = m_animator.GetCurrentAnimatorStateInfo(0); if (curState == null || !m_CurStateInfo.IsName(curState)) { curState = getCurState(); changeState(); } if (Player.instance.curState != null) Player.instance.curState.execute(this); }
static public int IsName(IntPtr l) { try{ UnityEngine.AnimatorStateInfo self = (UnityEngine.AnimatorStateInfo)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Boolean ret = self.IsName(a1); pushValue(l, ret); return(1); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int IsName(IntPtr L) { try { ToLua.CheckArgsCount(L, 2); UnityEngine.AnimatorStateInfo obj = (UnityEngine.AnimatorStateInfo)ToLua.CheckObject(L, 1, typeof(UnityEngine.AnimatorStateInfo)); string arg0 = ToLua.CheckString(L, 2); bool o = obj.IsName(arg0); LuaDLL.lua_pushboolean(L, o); ToLua.SetBack(L, 1, obj); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
// Update is called once per frame void Update() { if (GameObject.Find("SceneSand (1)") == null) { dialogAnimator.SetBool("SandInBag", true); } if (dialogAnimator.GetCurrentAnimatorStateInfo(0).IsName("portal")) { portal.SetActive(true); } if (Input.GetKeyDown("space")) { dialogAnimator.SetTrigger("Space"); indicator = dialogAnimator.GetCurrentAnimatorStateInfo(0); if (indicator.IsName("HelloThereWait")) { dialogAnimator.SetBool("gap1", true); } else if (indicator.IsName("SelfIntroductionWait")) { dialogAnimator.SetBool("gap2", true); } else if (indicator.IsName("HelpMeWait")) { dialogAnimator.SetBool("gap3", true); } else if (indicator.IsName("TryThisWait")) { dialogAnimator.SetBool("gap4", true); } else if (indicator.IsName("Rain")) { dialogAnimator.SetBool("getRain", true); if (cloud != null) { cloud.SetActive(true); } } else if (dialogAnimator.GetBool("granite") == true && indicator.IsName("GraniteGot")) { dialogAnimator.SetBool("gap5", true); } else if (indicator.IsName("rememberWait")) { dialogAnimator.SetBool("remember", true); } else if (dialogAnimator.GetBool("gotSand") == true && indicator.IsName("gotSand")) { dialogAnimator.SetBool("gap6", true); } else if (indicator.IsName("endWait")) { dialogAnimator.SetBool("gap7", true); } } else { dialogAnimator.ResetTrigger("Space"); } }
// methods static bool AnimatorStateInfo_IsName__String(JSVCall vc, int argc) { int len = argc; if (len == 1) { System.String arg0 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg); UnityEngine.AnimatorStateInfo argThis = (UnityEngine.AnimatorStateInfo)vc.csObj; JSApi.setBooleanS((int)JSApi.SetType.Rval, (System.Boolean)(argThis.IsName(arg0))); JSMgr.changeJSObj(vc.jsObjID, argThis); } return(true); }