Exemplo n.º 1
0
    void DetectController()
    {
        // right hand
        if (right_hand.grab_joystick)
        {
            if (!CustomHelper.MOL(right_hand.transform.rotation.eulerAngles.x, right_hand.rot_offset.eulerAngles.x, joystick_deadzone))
            {
                robot_input.x = right_hand.transform.rotation.eulerAngles.x - right_hand.rot_offset.eulerAngles.x;
            }

            if (!CustomHelper.MOL(right_hand.transform.rotation.eulerAngles.z, right_hand.rot_offset.eulerAngles.z, joystick_deadzone))
            {
                robot_input.z = right_hand.transform.rotation.eulerAngles.z - right_hand.rot_offset.eulerAngles.z;
            }

            if (!CustomHelper.MOL(right_hand.joystick_value.x, 0, joystick_deadzone))
            {
                robot_input.y = right_hand.joystick_value.x;
            }
        }
        else
        {
            robot_input = Vector3.zero;
        }

        // left hand
        if (left_hand.grab_joystick)
        {
            if (!CustomHelper.MOL(left_hand.transform.position.z, left_hand.pos_offset.z, handle_deadzone))
            {
                aim_input = left_hand.transform.position - left_hand.pos_offset;
            }
            else
            {
                aim_input = transform.forward;
            }
        }
    }