private void GrabObject(ControllerInformation info)
    {
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)info.GetFunctionalityInfoByType(typeof(GrabObjectInformation));

        grabObjInfo.objectInHand    = grabObjInfo.collidingObject;
        grabObjInfo.collidingObject = null;
        //objectInHand.transform.position = Vector3.Lerp(transform.position,objectInHand.transform.position, 0.8f);
        if (!info.trackedObj.GetComponent <FixedJoint>())
        {
            var joint = AddFixedJoint(info);
            joint.connectedBody = grabObjInfo.objectInHand.GetComponent <Rigidbody>();
        }
        if (grabObjInfo.objectInHand.gameObject.name == "Cube")
        {
            Cube = grabObjInfo.objectInHand.GetComponent <ThrowObject>();
            if (Cube)
            {
                if (Cube.taskCompleted[0] != null)
                {
                    {
                        Cube.taskCompleted[0].Invoke();
                    }
                }
            }
        }
    }
    private void ReleaseObject(ControllerInformation info)
    {
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)info.GetFunctionalityInfoByType(typeof(GrabObjectInformation));


        FixedJoint[] joints = info.trackedObj.gameObject.GetComponents <FixedJoint>();
        if (joints != null && joints.Length > 0)
        {
            foreach (var item in joints)
            {
                item.connectedBody = null;
                Destroy(item);
            }
        }
        if (grabObjInfo.objectInHand == null)
        {
            return;
        }
        grabObjInfo.objectInHand.GetComponent <Rigidbody>().velocity        = Quaternion.Euler(0, 180, 0) * controllerManager.GetController(info.trackedObj).velocity;
        grabObjInfo.objectInHand.GetComponent <Rigidbody>().angularVelocity = Quaternion.Euler(0, 180, 0) * controllerManager.GetController(info.trackedObj).angularVelocity;


        if (grabObjInfo.ObjectReleased != null)
        {
            grabObjInfo.ObjectReleased.Invoke(grabObjInfo.objectInHand);
        }

        grabObjInfo.objectInHand = null;
    }
    public void ForceGrab(GameObject go, ControllerInformation info)
    {
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)info.GetFunctionalityInfoByType(typeof(GrabObjectInformation));

        ReleaseObject(info);
        grabObjInfo.collidingObject = go;
        GrabObject(info);
    }
    /// <summary>
    /// In here we check if the collision that jsut occured is relevant
    /// </summary>
    private void SetCollidingObject(Collider col, ControllerInformation info)
    {
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)info.GetFunctionalityInfoByType(typeof(GrabObjectInformation));

        if (grabObjInfo.collidingObject || !col.GetComponent <Rigidbody>() || col.GetComponent <SteamVR_TrackedObject>())
        {
            return;
        }
        grabObjInfo.collidingObject = col.gameObject;

        //Debug.Log("Collided with -> " +info.trackedObj + " - " + grabObjInfo.collidingObject.name);
    }
    private void TriggerExit(Collider other, VRSensor sensor)
    {
        ControllerInformation info        = controllerManager.GetControllerInfo(sensor.GetComponent <SteamVR_TrackedObject>());
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)info.GetFunctionalityInfoByType(typeof(GrabObjectInformation));

        if (!grabObjInfo.collidingObject)
        {
            return;
        }

        grabObjInfo.collidingObject = null;
    }
    protected override void AnyControllerUpdate(ControllerInformation controller)
    {
        GrabObjectInformation grabObjInfo = (GrabObjectInformation)controller.GetFunctionalityInfoByType(typeof(GrabObjectInformation));

        if (controllerManager.GetController(controller.trackedObj).GetHairTriggerDown())
        {
            if (grabObjInfo.collidingObject)
            {
                GrabObject(controller);
            }
        }

        if (controllerManager.GetController(controller.trackedObj).GetHairTriggerUp())
        {
            ReleaseObject(controller);
        }

        if (controllerManager.GetController(controller.trackedObj).GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            if (grabObjInfo.objectInHand != null)
            {
                if (grabObjInfo.objectInHand.GetComponent <Lighter>())
                {
                    grabObjInfo.objectInHand.GetComponent <Lighter>().StartFire();
                }
            }
        }

        if (controllerManager.GetController(controller.trackedObj).GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            if (grabObjInfo.objectInHand != null)
            {
                if (grabObjInfo.objectInHand.GetComponent <Lighter>())
                {
                    grabObjInfo.objectInHand.GetComponent <Lighter>().StopFire();
                }
            }
        }
    }
 protected override void Awake()
 {
     info = new GrabObjectInformation();
     base.Awake();
 }