Beispiel #1
0
 public void Stop()
 {
     if (Node.IsTraversable == false)
     {
         SetPosition(_lastTraversablePosition);
     }
     VelocityHandler?.Invoke(Vector2.zero, FacingDirection);
 }
Beispiel #2
0
    public void Translate(Vector2 normalizedDestination)
    {
        _gameObject.transform.Translate(normalizedDestination * (_speed * Time.deltaTime));
        VelocityHandler?.Invoke(normalizedDestination, FacingDirection);

        Node currentNode = Utils.NodeAt(Utils.ToVector2Int(WorldPosition));

        if (currentNode.IsTraversable)
        {
            OnGridPositionChange?.Invoke(_lastTraversablePosition, currentNode.Position);
            _lastTraversablePosition = currentNode.Position;
        }
        OnPositionChange?.Invoke(WorldPosition);
    }