Ejemplo n.º 1
0
        private void MoveToPosition(Vector3 position)
        {
            var targetDirection = VectorUtilities.Direction(transform.position, position);

            var angleDirection = AngleUtilities.AngleDirection(transform.forward, targetDirection, transform.up);

            var isBehind = AngleUtilities.AngleIsBehind(transform.forward, targetDirection);

            if (isBehind && angleDirection == 0)
            {
                _moveComponent.MoveBack(Time.fixedDeltaTime);
                return;
            }

            _moveComponent.MoveForward(Time.fixedDeltaTime);

            switch (angleDirection)
            {
            case -1:
                _moveComponent.TurnLeft(Time.fixedDeltaTime);
                break;

            case 1:
                _moveComponent.TurnRight(Time.fixedDeltaTime);
                break;

            case 0:
                break;
            }
        }
Ejemplo n.º 2
0
 private void FixedUpdate()
 {
     if (_upPressed)
     {
         _moveComponent.MoveForward(Time.fixedDeltaTime);
     }
     if (_downPressed)
     {
         _moveComponent.MoveBack(Time.fixedDeltaTime);
     }
     if (_leftPressed)
     {
         _moveComponent.TurnLeft(Time.fixedDeltaTime);
     }
     if (_rightPressed)
     {
         _moveComponent.TurnRight(Time.fixedDeltaTime);
     }
 }