public override void Step(MoveDirection direction) { base.Step(direction); _animator.SetInteger(Dir, direction.ToAnimationNumber()); Vector3 currentForward = transform.forward; Vector3 newForward = direction.ToVector(); Vector3 rayPosition = transform.position + (Vector3.up / 2); _sequence = DOTween.Sequence(); if (Physics.Raycast(rayPosition, newForward, 0.5f, GameManager.Instance.groundLayerMask) && !GameManager.Instance.godMode) { _animator.SetTrigger(CantMove); return; } if (currentForward == newForward) { _sequence.Append(transform.DOMove(transform.position + newForward, GameManager.Instance.stepTime).SetEase(GameManager.Instance.moveEase)); } else { float runtime = GameManager.Instance.stepTime; var position = transform.position; _sequence.Append(transform.DOLookAt(position + newForward, runtime).SetEase(GameManager.Instance.rotationEase)); _sequence.Append(transform.DOMove(position + newForward, runtime).SetEase(GameManager.Instance.moveEase)); } _sequence.Play(); _sequence.OnComplete(() => GameManager.Instance.StepFinished()); }
public void MovePlayer(MoveDirection move) { var(x, y) = move.ToVector(); Move(x, y); }