// Update is called once per frame void Update() { combatStateInfo = animator.GetCurrentAnimatorStateInfo(1); baseStateInfo = animator.GetCurrentAnimatorStateInfo(0); SetAnimation(requestedId); }
public override void OnSLStatePostEnter(Animator animator, AnimatorStateInfo stateIfno, int layerIndex) { monoBehaviour.ForceNotRangedAttack(); monoBehaviour.EnableMeleeDamager(); monoBehaviour.SetHorizontalMovement(monoBehaviour.meleeAttackDashSpeed * monoBehaviour.GetFacing()); }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { var animRepetition = (int)stateInfo.normalizedTime; var animTime = stateInfo.normalizedTime - animRepetition; if (!fireAnimTimeEvent) { goto multievent; } #region Timed to Anim if (!_fireTimedEvent && RetriggerWhenStateLoops) { // change back to true if "re-trigger" checked and anim has looped. if (_lastRepetition >= 0 && animRepetition > _lastRepetition) { _fireTimedEvent = true; } } if (_fireTimedEvent) { if (animTime > whenToFireEvent) { _fireTimedEvent = false; MasterAudio.FireCustomEvent(timedCustomEvent, _actorTrans); } } #endregion multievent: if (!fireMultiAnimTimeEvent) { goto afterMulti; } #region Fire Multiple Events Timed To Anim if (RetriggerWhenStateLoops) { if (!_playMultiEvent1) { // change back to true if "re-trigger" checked and anim has looped. if (_lastRepetition >= 0 && animRepetition > _lastRepetition) { _playMultiEvent1 = true; } } if (!_playMultiEvent2) { // change back to true if "re-trigger" checked and anim has looped. if (_lastRepetition >= 0 && animRepetition > _lastRepetition) { _playMultiEvent2 = true; } } if (!_playMultiEvent3) { // change back to true if "re-trigger" checked and anim has looped. if (_lastRepetition >= 0 && animRepetition > _lastRepetition) { _playMultiEvent3 = true; } } if (!_playMultiEvent4) { // change back to true if "re-trigger" checked and anim has looped. if (_lastRepetition >= 0 && animRepetition > _lastRepetition) { _playMultiEvent4 = true; } } } if (!_playMultiEvent1) { goto decideMulti2; } if (animTime < whenToFireMultiEvent1 || numOfMultiEventsToFire < 1) { goto decideMulti2; } _playMultiEvent1 = false; MasterAudio.FireCustomEvent(MultiTimedEvent, _actorTrans); decideMulti2: if (!_playMultiEvent2) { goto decideMulti3; } if (animTime < whenToFireMultiEvent2 || numOfMultiEventsToFire < 2) { goto decideMulti3; } _playMultiEvent2 = false; MasterAudio.FireCustomEvent(MultiTimedEvent, _actorTrans); decideMulti3: if (!_playMultiEvent3) { goto decideMulti4; } if (animTime < whenToFireMultiEvent3 || numOfMultiEventsToFire < 3) { goto decideMulti4; } _playMultiEvent3 = false; MasterAudio.FireCustomEvent(MultiTimedEvent, _actorTrans); decideMulti4: if (!_playMultiEvent4) { goto afterMulti; } if (animTime < whenToFireMultiEvent4 || numOfMultiEventsToFire < 4) { goto afterMulti; } _playMultiEvent4 = false; MasterAudio.FireCustomEvent(MultiTimedEvent, _actorTrans); #endregion afterMulti: _lastRepetition = animRepetition; }
override public void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo) { }
private CinemachineVirtualCameraBase ChooseCurrentCamera(float deltaTime) { //UnityEngine.Profiling.Profiler.BeginSample("CinemachineStateDrivenCamera.ChooseCurrentCamera"); if (m_ChildCameras == null || m_ChildCameras.Length == 0) { mActivationTime = 0; //UnityEngine.Profiling.Profiler.EndSample(); return(null); } CinemachineVirtualCameraBase defaultCam = m_ChildCameras[0]; if (m_AnimatedTarget == null || !m_AnimatedTarget.gameObject.activeSelf || m_AnimatedTarget.runtimeAnimatorController == null || m_LayerIndex < 0 || m_LayerIndex >= m_AnimatedTarget.layerCount) { mActivationTime = 0; //UnityEngine.Profiling.Profiler.EndSample(); return(defaultCam); } // Get the current state int hash; if (m_AnimatedTarget.IsInTransition(m_LayerIndex)) { // Force "current" state to be the state we're transitionaing to AnimatorStateInfo info = m_AnimatedTarget.GetNextAnimatorStateInfo(m_LayerIndex); hash = info.fullPathHash; if (m_AnimatedTarget.GetNextAnimatorClipInfoCount(m_LayerIndex) > 1) { m_AnimatedTarget.GetNextAnimatorClipInfo(m_LayerIndex, m_clipInfoList); hash = GetClipHash(info.fullPathHash, m_clipInfoList); } } else { AnimatorStateInfo info = m_AnimatedTarget.GetCurrentAnimatorStateInfo(m_LayerIndex); hash = info.fullPathHash; if (m_AnimatedTarget.GetCurrentAnimatorClipInfoCount(m_LayerIndex) > 1) { m_AnimatedTarget.GetCurrentAnimatorClipInfo(m_LayerIndex, m_clipInfoList); hash = GetClipHash(info.fullPathHash, m_clipInfoList); } } // If we don't have an instruction for this state, find a suitable default while (hash != 0 && !mInstructionDictionary.ContainsKey(hash)) { hash = mStateParentLookup.ContainsKey(hash) ? mStateParentLookup[hash] : 0; } float now = Time.time; if (mActivationTime != 0) { // Is it active now? if (mActiveInstruction.m_FullHash == hash) { // Yes, cancel any pending mPendingActivationTime = 0; //UnityEngine.Profiling.Profiler.EndSample(); return(mActiveInstruction.m_VirtualCamera); } // Is it pending? if (deltaTime >= 0) { if (mPendingActivationTime != 0 && mPendingInstruction.m_FullHash == hash) { // Has it been pending long enough, and are we allowed to switch away // from the active action? if ((now - mPendingActivationTime) > mPendingInstruction.m_ActivateAfter && ((now - mActivationTime) > mActiveInstruction.m_MinDuration || mPendingInstruction.m_VirtualCamera.Priority > mActiveInstruction.m_VirtualCamera.Priority)) { // Yes, activate it now mActiveInstruction = mPendingInstruction; mActivationTime = now; mPendingActivationTime = 0; } //UnityEngine.Profiling.Profiler.EndSample(); return(mActiveInstruction.m_VirtualCamera); } } } // Neither active nor pending. mPendingActivationTime = 0; // cancel the pending, if any if (!mInstructionDictionary.ContainsKey(hash)) { // No defaults set, we just ignore this state if (mActivationTime != 0) { return(mActiveInstruction.m_VirtualCamera); } //UnityEngine.Profiling.Profiler.EndSample(); return(defaultCam); } // Can we activate it now? Instruction newInstr = m_Instructions[mInstructionDictionary[hash]]; if (newInstr.m_VirtualCamera == null) { newInstr.m_VirtualCamera = defaultCam; } if (deltaTime >= 0 && mActivationTime > 0) { if (newInstr.m_ActivateAfter > 0 || ((now - mActivationTime) < mActiveInstruction.m_MinDuration && newInstr.m_VirtualCamera.Priority <= mActiveInstruction.m_VirtualCamera.Priority)) { // Too early - make it pending mPendingInstruction = newInstr; mPendingActivationTime = now; if (mActivationTime != 0) { return(mActiveInstruction.m_VirtualCamera); } //UnityEngine.Profiling.Profiler.EndSample(); return(defaultCam); } } // Activate now mActiveInstruction = newInstr; mActivationTime = now; //UnityEngine.Profiling.Profiler.EndSample(); return(mActiveInstruction.m_VirtualCamera); }
// 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) { animator.transform.parent.GetComponent <EnemyHedgehog>().AnimationEvent_SetStateBackToIdle(); }
virtual protected void Routine() { state = animator.GetCurrentAnimatorStateInfo(0); }
// 以下、メイン処理.リジッドボディと絡めるので、FixedUpdate内で処理を行う. void FixedUpdate() { float h = Input.GetAxis("Horizontal"); // 入力デバイスの水平軸をhで定義 float v = Input.GetAxis("Vertical"); // 入力デバイスの垂直軸をvで定義 //Debug.Log ("v" + v); //if (v >= 0) { // anim.SetFloat ("Speed", v); // Animator側で設定している"Speed"パラメタにvを渡す // } anim.SetFloat("Direction", h); // Animator側で設定している"Direction"パラメタにhを渡す anim.speed = animSpeed; // Animatorのモーション再生速度に animSpeedを設定する currentBaseState = anim.GetCurrentAnimatorStateInfo(0); // 参照用のステート変数にBase Layer (0)の現在のステートを設定する rb.useGravity = true; //ジャンプ中に重力を切るので、それ以外は重力の影響を受けるようにする // 以下、キャラクターの移動処理 if (v > 0) { velocity = new Vector3(0, 0, v); // 上下のキー入力からZ軸方向の移動量を取得 } else { velocity = new Vector3(0, 0, 0); } // キャラクターのローカル空間での方向に変換 velocity = transform.TransformDirection(velocity); //以下のvの閾値は、Mecanim側のトランジションと一緒に調整する if (v > 0.1) { velocity *= forwardSpeed; // 移動速度を掛ける } else if (v < -0.1) { velocity *= backwardSpeed; // 移動速度を掛ける } if (Input.GetButtonDown("Jump")) // スペースキーを入力したら //アニメーションのステートがLocomotionかidleの最中のみジャンプできる { if ((currentBaseState.fullPathHash == locoState) || (currentBaseState.fullPathHash == idleState)) { //if (currentBaseState.nameHash == locoState) { //ステート遷移中でなかったらジャンプできる if (!anim.IsInTransition(0)) { //rb.AddForce (Vector3.up * jumpPower, ForceMode.VelocityChange); anim.SetBool("Jump", true); // Animatorにジャンプに切り替えるフラグを送る } // } else if ((currentBaseState.nameHash == idleState)) { // //ステート遷移中でなかったらジャンプできる // if (!anim.IsInTransition (0)) { // rb.AddForce (Vector3.up * (jumpPower / 4), ForceMode.VelocityChange); // anim.SetBool ("Jump", true); // Animatorにジャンプに切り替えるフラグを送る // } } } // 上下のキー入力でキャラクターを移動させる transform.localPosition += velocity * Time.fixedDeltaTime; anim.SetFloat("Speed", v); // 左右のキー入力でキャラクタをY軸で旋回させる transform.Rotate(0, h * rotateSpeed, 0); // 以下、Animatorの各ステート中での処理 // Locomotion中 // 現在のベースレイヤーがlocoStateの時 if (currentBaseState.fullPathHash == locoState) { //カーブでコライダ調整をしている時は、念のためにリセットする if (useCurves) { resetCollider(); } } // JUMP中の処理 // 現在のベースレイヤーがjumpStateの時 else if ((currentBaseState.fullPathHash == jumpDashState) || (currentBaseState.fullPathHash == jumpState)) { cameraObject.SendMessage("setCameraPositionJumpView"); // ジャンプ中のカメラに変更 // ステートがトランジション中でない場合 if (!anim.IsInTransition(0)) { // 以下、カーブ調整をする場合の処理 if (useCurves) { // 以下JUMP00アニメーションについているカーブJumpHeightとGravityControl // JumpHeight:JUMP00でのジャンプの高さ(0〜1) // GravityControl:1⇒ジャンプ中(重力無効)、0⇒重力有効 float jumpHeight = anim.GetFloat("JumpHeight"); float gravityControl = anim.GetFloat("GravityControl"); if (gravityControl > 0) { rb.useGravity = false; //ジャンプ中の重力の影響を切る } // レイキャストをキャラクターのセンターから落とす // Ray ray = new Ray (transform.position + Vector3.up, -Vector3.up); // RaycastHit hitInfo = new RaycastHit (); // 高さが useCurvesHeight 以上ある時のみ、コライダーの高さと中心をJUMP00アニメーションについているカーブで調整する // if (Physics.Raycast (ray, out hitInfo)) { // if (hitInfo.distance > useCurvesHeight) { //col.height = orgColHight - jumpHeight; // 調整されたコライダーの高さ // float adjCenterY = orgVectColCenter.y + jumpHeight; //col.center = new Vector3 (0, adjCenterY, 0); // 調整されたコライダーのセンター //} else { // 閾値よりも低い時には初期値に戻す(念のため) // resetCollider (); //} // } } // Jump bool値をリセットする(ループしないようにする) anim.SetBool("Jump", false); } } // IDLE中の処理 // 現在のベースレイヤーがidleStateの時 else if (currentBaseState.fullPathHash == idleState) { //カーブでコライダ調整をしている時は、念のためにリセットする if (useCurves) { resetCollider(); } } else if ((currentBaseState.fullPathHash == jumpState) || (currentBaseState.fullPathHash == jumpDashState)) { anim.SetBool("Jump", false); } }
// 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) { player = GameManager.Instance.player; playercontroller = player.GetComponent <PlayerController>(); playerattack = player.GetComponent <PlayerAttack>(); }
// 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 override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { playerattack.playingSkill = false; playerattack.SkillEnd(); playercontroller.playerState = PlayerState.Idle; }
public override void OnExit(StateBase sb, Animator anim, AnimatorStateInfo animStateInfo) { }
public override void OnStart(StateBase sb, Animator anim, AnimatorStateInfo animStateInfo) { Movement _charMovement = sb.GetCharMovement(anim); _charMovement.Rigid.gravityScale = 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) { ms = animator.GetComponent <MonsterScript>(); }
//OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { ms.reactToPosition(); }
public override void OnExit(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo) { }
// Use this for initialization void Start() { animator = GetComponent<Animator>(); combatStateInfo = animator.GetCurrentAnimatorStateInfo(1); baseStateInfo = animator.GetCurrentAnimatorStateInfo(0); }
private IEnumerator SetCurrentTrigger(AnimationLayer layer) { yield return new WaitForEndOfFrame(); int layerId = GetLayerId(layer); stateInfo = animator.GetCurrentAnimatorStateInfo(layerId); SetCurrentTrigger(layer, stateInfo.fullPathHash); }
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Physics2D.IgnoreCollision(animator.GetComponent <Collider2D>(), Player.Instance.GetComponent <Collider2D>(), false); }
protected virtual void OnAnimatorStateExitInternal( PlayerController control, AnimatorStateInfo stateInfo) { }
// 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) { animator.SetBool(IsAttacking, true); animator.SetBool(ClickedForTheNextAttack, false); }
public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { }
public override void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo) { //There is no update ability from this move for now }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { disableInput.Value = true; hasTriggeredTheEvent = false; }
public override void OnEnter(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo) { animator.SetBool(TransitionParameter.WheelRoll.ToString(), false); animator.SetBool(TransitionParameter.Move.ToString(), false); animator.SetBool(TransitionParameter.SpringThrow.ToString(), false); }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { StateMachine = animator.GetBehaviour <AiStateMachine>(); StateMachine.CurrentAiBrain.Base = AiBase; }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { }
public override void OnEnter(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo) { CharacterControl control = characterState.GetCharacterControl(animator); control.SkinnedMeshAnimator.applyRootMotion = true; }
// 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) { animator.GetComponent <bossLife>().isInvulnerable = true; }
public override void OnSLStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { monoBehaviour.DisableMeleeDamager(); }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { Event.Raise(); }
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateUpdate(animator, stateInfo, layerIndex); NPC.transform.LookAt(new Vector3(player.transform.position.x, NPC.transform.position.y, player.transform.position.z)); }
// 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) { FindObjectOfType <MusicManager>().PlayJump(); }
// 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 override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { animator.SetBool("MoveUp", false); }
public void SetAnimation(AnimationName name, AnimationLayer layer, bool blocking=false) { if (DefaultClient.OptimizeForServer()) { return; } int layerId = GetLayerId(layer); if (animator.IsInTransition(layerId)) { return; } stateInfo = animator.GetCurrentAnimatorStateInfo(layerId); if (blockingId != -1) { AnimatorStateInfo blockInfo = animator.GetCurrentAnimatorStateInfo(blockingLayer); if (blockState == BlockState.PreAnimation) { if (blockInfo.fullPathHash == blockingId) { blockState = BlockState.Animation; } return; } else if (blockState == BlockState.Animation) { if (blockInfo.fullPathHash == blockingId) { return; } else { blockingId = -1; blockState = BlockState.None; } } } int triggerId = GetTriggerId(name, layer); int currentTrigger = GetCurrentTrigger(layer); if (blocking) { blockingId = triggerId; blockingLayer = layerId; blockState = BlockState.PreAnimation; } if (currentTrigger == triggerId) { if (Time.time - lastReset > 0.20 && currentTrigger != stateInfo.fullPathHash) { SetCurrentTrigger(layer, stateInfo.fullPathHash); lastReset = Time.time; } else { return; } } if (stateInfo.fullPathHash == triggerId) { return; } animator.SetTrigger(triggerId); SetCurrentTrigger(layer, triggerId); }