private void Update() { var prevAnim = currentAnim; if (MoveX == 1) { currentAnim = walkRightAnim; } else if (MoveX == -1) { currentAnim = walkLeftAnim; } else if (MoveY == 1) { currentAnim = walkUpAnim; } else if (MoveY == -1) { currentAnim = walkDownAnim; } if (currentAnim != prevAnim || IsMoving != wasPreviouslyMoving) currentAnim.Start(); if (IsMoving) { currentAnim.HandleUpdate(); } else { spriteRenderer.sprite = currentAnim.Frames[0]; } wasPreviouslyMoving = IsMoving; }
private void Update() { UpdateAnimator(); if (isPaused) { return; } currentAnimator.HandleUpdate(); }
private void Update() { var prevAnim = currentAnim; if (MoveX == 1) { currentAnim = walkRightAnim; } else if (MoveX == -1) { currentAnim = walkLeftAnim; } else if (MoveY == 1) { currentAnim = walkUpAnim; } else if (MoveY == -1) { currentAnim = walkDownAnim; } if (currentAnim != prevAnim || IsMoving != wasPrevMoving) { currentAnim.Start(); } //If the player is moving, we show the whole animation, else we just show the first frame since she is just standing up if (IsMoving) { currentAnim.HandleUpdate(); } else { spriteRenderer.sprite = currentAnim.Frames[0]; } wasPrevMoving = IsMoving; }