Skip to content

Instantly share code, notes, and snippets.

@okputadora
Last active February 14, 2021 20:28
Show Gist options
  • Save okputadora/5292f7e94260600ff3446abcbf52ae39 to your computer and use it in GitHub Desktop.
Save okputadora/5292f7e94260600ff3446abcbf52ae39 to your computer and use it in GitHub Desktop.
Unity Character Aiming with Animation Rigging
private void Animate()
{
playerAnimator.SetFloat("speed", Mathf.Max(Mathf.Abs(horizontalInput), Mathf.Abs(verticalInput)));
if (isAiming)
{
if (aimPose.weight < 1)
{
aimPose.weight = Mathf.Lerp(aimPose.weight, 1, Time.deltaTime * poseTransitionSpeed);
}
/* if (isShooting)
{
playerAnimator.SetBool("isShooting", true);
}*/
playerAnimator.SetBool("isAiming", true);
}
else
{
playerAnimator.SetBool("isAiming", false);
playerAnimator.SetBool("isShooting", false);
if (aimPose.weight > 0)
{
aimPose.weight = Mathf.Lerp(aimPose.weight, 0, Time.deltaTime * poseTransitionSpeed);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment