Skip to content

Instantly share code, notes, and snippets.

@SiunCyclone
Created June 1, 2020 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiunCyclone/7cd47a0b9e407c31bf6e20c26ced0a5f to your computer and use it in GitHub Desktop.
Save SiunCyclone/7cd47a0b9e407c31bf6e20c26ced0a5f to your computer and use it in GitHub Desktop.
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