private void HandleMovement() { float currentSpeed = walkSpeed; float currentMaxSpeed = walkMaxspeed; animationCurrentSpeed = animationWalkSpeed; if (inputAdapter.GetInput(InputAdapter.InputKey.TRIGGER)) { if (sprintTimeLeft >= 0) { sprintTimeLeft -= Time.deltaTime; currentSpeed = sprintSpeed; currentMaxSpeed = sprintMaxSpeed; carrot = null; onSprint?.Invoke(); animationCurrentSpeed = animationRunSpeed; } } else { sprintTimeLeft = Mathf.Min(sprintTimeLeft + sprintRecoverRate * Time.deltaTime, sprintMaxTime); } Vector3 newVel = inputAdapter.GetVelocity(body.velocity, currentSpeed); animationCurrentSpeed = Mathf.Min(animationCurrentSpeed, newVel.magnitude); animator.SetFloat("speed", animationCurrentSpeed); if (animationCurrentSpeed > 0.1f) { bird.start = true; } body.velocity = newVel; if (body.velocity.magnitude > 0.1f) { transform.rotation = Quaternion.LookRotation(body.velocity, Vector3.up); if (nextFootPrintsTime <= Time.time) { nextFootPrintsTime = Time.time + UnityEngine.Random.Range(timeBetweenFootPrintsMin, timeBetweenFootPrintsMax); GameObject newFoorPrint = Instantiate(footPrintsPrefab, footPrintsContainer); newFoorPrint.transform.position = new Vector3(transform.position.x, 0.1f, transform.position.z); newFoorPrint.transform.rotation = Quaternion.Euler(90, transform.rotation.eulerAngles.y + UnityEngine.Random.Range(-20, 20), transform.rotation.eulerAngles.z + UnityEngine.Random.Range(-20, 20)); Sequence sequence = DOTween.Sequence(); sequence.AppendInterval(timeBeforeShrink) .Append(newFoorPrint.transform.DOScale(Vector3.zero, shrinkDuration)) .OnComplete(() => Destroy(newFoorPrint)); playsound++; if (playsound % 4 == 0) { soundManager.PlaySnowSound(); } } } }