Created
June 1, 2020 16:26
-
-
Save SiunCyclone/7cd47a0b9e407c31bf6e20c26ced0a5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Update(ref CharacterInterpolatedData animState) { | |
// Set supported animation state bools | |
for (var i = 0; i < m_supportedAnimStates.Length; i++) | |
m_animatorController.SetBool(m_supportedAnimStates[i].hash, animState.charLocoState == m_supportedAnimStates[i].state); | |
// Set supported action state bools | |
for (var i = 0; i < m_supportedActionStates.Length; i++) | |
m_animatorController.SetBool(m_supportedActionStates[i].hash, animState.charAction == m_supportedActionStates[i].action); | |
// Set supported triggers | |
if (animState.charAction != m_lastActionTriggered || animState.charActionTick != lastActionTick) { | |
// Clear last trigger | |
if (m_lastActionTriggered != CharacterPredictedData.Action.None) { | |
m_animatorController.ResetTrigger(m_supportedActionTriggers[(int) m_lastActionTriggered]); | |
} | |
m_lastActionTriggered = CharacterPredictedData.Action.None; | |
// Trigger new action trigger if it is supported | |
if (m_supportedActionTriggers[(int) animState.charAction] != 0) { | |
m_lastActionTriggered = animState.charAction; | |
m_animatorController.SetTrigger(m_supportedActionTriggers[(int) m_lastActionTriggered]); | |
} | |
} | |
lastActionTick = animState.charActionTick; | |
m_animatorController.SetBool(m_sprintState, animState.sprinting == 1); | |
if (animState.damageTick > m_lastReactionTick + m_waitFor) { | |
m_animatorController.SetTrigger(m_hitReaction); | |
m_lastReactionTick = animState.damageTick; | |
Random.InitState(animState.damageTick); | |
m_waitFor = Random.Range(4, 6); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment