void Update()
    {
        // Joystick controller
        float x = DGameSystem.joystick.Horizontal;
        float y = DGameSystem.joystick.Vertical;

        if (x == 0 && y == 0)
        {
            movement.Stand();
            return;
        }

        if (Mathf.Abs(x) > Mathf.Abs(y))
        {
            if (x > 0)
            {
                movement.state = "go_right";
            }
            else
            {
                movement.state = "go_left";
            }
        }
        else
        {
            if (y > 0)
            {
                movement.state = "go_up";
            }
            else
            {
                movement.state = "go_down";
            }
        }
    }
예제 #2
0
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }

        // Joystick controller
        float x = joystick.Horizontal;
        float y = joystick.Vertical;

        if (x == 0 && y == 0)
        {
            playerMovement.Stand();
            return;
        }

        if (Mathf.Abs(x) > Mathf.Abs(y))
        {
            if (x > 0)
            {
                playerMovement.state = "go_right";
            }
            else
            {
                playerMovement.state = "go_left";
            }
        }
        else
        {
            if (y > 0)
            {
                playerMovement.state = "go_up";
            }
            else
            {
                playerMovement.state = "go_down";
            }
        }
    }
예제 #3
0
    void Update()
    {
        rigid.velocity = new Vector3(joystick.Horizontal, joystick.Vertical);

        // Joystick controller
        float x = joystick.Horizontal;
        float y = joystick.Vertical;

        if (x == 0 && y == 0)
        {
            playerMovement.Stand();
            return;
        }

        if (Mathf.Abs(x) > Mathf.Abs(y))
        {
            if (x > 0)
            {
                playerMovement.state = "go_right";
            }
            else
            {
                playerMovement.state = "go_left";
            }
        }
        else
        {
            if (y > 0)
            {
                playerMovement.state = "go_up";
            }
            else
            {
                playerMovement.state = "go_down";
            }
        }
    }