// FixedUpdate is called on a timer void FixedUpdate() { //block cooldown countdown m_blockCooldown -= Time.fixedDeltaTime; m_dashCooldown -= Time.fixedDeltaTime; m_shootCooldown -= Time.fixedDeltaTime; // State machine shenanigans if (!m_initialised) { return; } if (m_currentGameState != null) { m_currentGameState.UpdateState(); } if (m_nextGameStateIndex != CharacterStateNames.NullState) { if (m_currentGameState != null) { m_currentGameState.ExitState(m_nextGameStateIndex); } m_currentGameState = m_gameStateDictionary[m_nextGameStateIndex]; m_currentGameState.EnterState(m_currentGameStateIndex); m_currentGameStateIndex = m_nextGameStateIndex; m_nextGameStateIndex = CharacterStateNames.NullState; } m_grounded = false; }
//Change the game state (occurs on next frame) public void ChangePlayerState(CharacterStateNames nextState) { if (!m_gameStateDictionary.ContainsKey(nextState)) { return; } m_animator.SetInteger(HashIDs.State, (int)nextState); if (m_nextGameStateIndex == CharacterStateNames.DeadState) { return; } if (m_nextGameStateIndex == CharacterStateNames.HurtState) { return; } m_nextGameStateIndex = nextState; }