Exemplo n.º 1
0
    public void SendRotationValues()
    {
        mouseX = Input.GetAxis("Mouse X") * Time.fixedDeltaTime;
        mouseY = Input.GetAxis("Mouse Y") * Time.fixedDeltaTime;

        playerLook.SetRotationY(mouseX);

        xRotation -= mouseY;
        xRotation  = Mathf.Clamp(xRotation, -90f, 90f);
        playerLook.SetRotationX(xRotation);
    }
Exemplo n.º 2
0
    void Update()
    {
        if (!isTouched)
        {
            if (Input.touchCount > 0)
            {
                int i = Input.touchCount;

                for (int j = 0; j < i; j++)
                {
                    if (Input.GetTouch(j).phase == TouchPhase.Began && Input.GetTouch(j).position.x > (screenWidth / 2.3))// Click on the right side of the screen
                    {
                        dragOrigin = Input.GetTouch(j).position;
                        idTouch    = Input.GetTouch(j).fingerId;
                        isTouched  = true;
                        dragX      = 0f;
                        dragY      = 0f;
                        lastDragX  = 0f;
                        lastDragY  = 0f;
                        return;
                    }
                }
            }
        }
        else
        {
            int k = 0;
            while (Input.GetTouch(k).fingerId != idTouch)
            {
                k++;
            }

            if (Input.GetTouch(k).phase == TouchPhase.Moved)
            {
                dragFromOrigin = Input.GetTouch(k).position - dragOrigin;
                dragX          = dragFromOrigin.x * 100f / screenWidth;
                dragY          = dragFromOrigin.y * 100f / screenHeight;

                xRotation = lastDragX - dragX;
                yRotation = lastDragY - dragY;

                lastDragX = dragX;
                lastDragY = dragY;

                playerLook.SetRotationX(xRotation * 2);
                playerLook.SetRotationY(yRotation * 2);
            }
            else if (Input.GetTouch(k).phase == TouchPhase.Ended)
            {
                isTouched = false;
            }
        }
    }
Exemplo n.º 3
0
    public void FixedUpdate()
    {
        Vector3 direction = Vector3.forward * variableJoystickMove.Vertical + Vector3.right * variableJoystickMove.Horizontal;

        playerMove.SetDirection(direction);

        float rotationX = -variableJoystickLook.Vertical;
        float rotationY = variableJoystickLook.Horizontal;

        playerLook.SetRotationX(rotationX * .25f);
        playerLook.SetRotationY(rotationY * .25f);

        //player.transform.position += direction * speed * Time.fixedDeltaTime;

        //rb.AddForce(direction * speed * Time.fixedDeltaTime, ForceMode.VelocityChange);
    }