Ejemplo n.º 1
0
 void FixedUpdate()
 {
     if (!isMoving)
     {
         pauseMoving();
         return;
     }
     if (forward == 0 && right == 0)
     {
         spriteMover.pauseMoving();
         return;
     }
     if (forward < 0f)
     {
         spriteMover.moveForward(forward);
     }
     else if (forward > 0f)
     {
         spriteMover.moveBackward(forward);
     }
     if (right > 0f)
     {
         spriteMover.moveRight(right);
     }
     else if (right < 0f)
     {
         spriteMover.moveLeft(right);
     }
 }
    void FixedUpdate()
    {
        if (isTalking)
        {
            spriteMover.pauseMoving();
            return;
        }

        right   = Input.GetAxisRaw("Horizontal");
        forward = Input.GetAxisRaw("Vertical");

        if (Input.GetKey(KeyCode.LeftShift))
        {
            currentSpeed = speedMultiplier;
        }
        else
        {
            currentSpeed = 1f;
        }

        if (forward == 0 && right == 0)
        {
            spriteMover.pauseMoving();
            return;
        }

        if (right > 0f)
        {
            spriteMover.moveRight(right * currentSpeed);
        }
        else if (right < 0f)
        {
            spriteMover.moveLeft(right * currentSpeed);
            return;
        }

        if (forward < 0f)
        {
            spriteMover.moveForward(forward * currentSpeed);
        }
        else if (forward > 0f)
        {
            spriteMover.moveBackward(forward * currentSpeed);
        }
    }