private void FixedUpdate() { currentPosition = heroTransform.position; if (Mathf.Ceil(currentPosition.x) != Mathf.Ceil(targetPosition.x) || Mathf.Ceil(currentPosition.y) != Mathf.Ceil(targetPosition.y)) { Vector2 roundedTarget = new Vector2(Mathf.RoundToInt(targetPosition.x), Mathf.RoundToInt(targetPosition.y)); Vector2 roundedCurrent = new Vector2(Mathf.RoundToInt(currentPosition.x), Mathf.RoundToInt(currentPosition.y)); Vector2 directionMovement = (roundedTarget - roundedCurrent).normalized; directionMovement.x = Mathf.Round(directionMovement.x); directionMovement.y = Mathf.Round(directionMovement.y); Vector2 movement = directionMovement * movementSpeed; Vector2 newPosition = currentPosition + movement * Time.fixedDeltaTime; heroRigidbody.MovePosition(newPosition); characterAnimatorScript.AnimateRun(targetPosition); } else { if (pathFinding.path != null && pathFinding.path.Count > 0) { targetPosition = pathFinding.path.Pop(); } characterAnimatorScript.AnimateStatic(); heroPositionAndState.Position = targetPosition; heroPositionAndState.IsAtPosition = true; placeSelectEvent.Raise(heroPositionAndState); } }
public void WaitOnActualPosition() { troopAnimations.AnimateStatic(); }