Example #1
0
    private IEnumerator FindDevices()
    {
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        UIPointerR      = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_UIPointer>();
        UIPointerL      = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_UIPointer>();
        HeadsetTranform = VRTK_DeviceFinder.HeadsetTransform();
    }
        public override Transform GetLeftHand()
        {
#if VRTK_DEFINE_SDK_STEAMVR
            if (VRTK_DeviceFinder.GetControllerLeftHand() != null)
            {
                return(VRTK_DeviceFinder.GetControllerLeftHand().transform);
            }
#endif
            return(null);
        }
Example #3
0
 IEnumerator FindControllers()
 {
     while (leftController == null && rightController == null)
     {
         leftController  = VRTK_DeviceFinder.GetControllerLeftHand();
         rightController = VRTK_DeviceFinder.GetControllerRightHand();
         yield return(null);
     }
     Init();
 }
Example #4
0
    public void Start()
    {
        GameObject leftController = VRTK_DeviceFinder.GetControllerLeftHand();

        leftController.GetComponent <VRTK_ControllerEvents>().ControllerEnabled += controllerEnabledHandler;

        GameObject rightController = VRTK_DeviceFinder.GetControllerRightHand();

        rightController.GetComponent <VRTK_ControllerEvents>().ControllerDisabled += controllerDisabledHandler;
    }
Example #5
0
        protected override void Start()
        {
            base.Start();

            rb = controlObject.GetComponent <Rigidbody>();
            rb.maxAngularVelocity = 7f;

            leftCtrlEvents  = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_ControllerEvents>();
            rightCtrlEvents = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_ControllerEvents>();
        }
Example #6
0
    void FindControllers()
    {
        if (!VRTK_ControllerReference.IsValid(leftController))
        {
            leftController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerLeftHand());
        }

        if (!VRTK_ControllerReference.IsValid(rightController))
        {
            rightController = VRTK_ControllerReference.GetControllerReference(VRTK_DeviceFinder.GetControllerRightHand(true));
        }
    }
Example #7
0
 private bool NoArrowNotched(GameObject controller)
 {
     if (VRTK_DeviceFinder.IsControllerLeftHand(controller))
     {
         bow = VRTK_DeviceFinder.GetControllerRightHand(true).GetComponentInChildren <BowAim>();
     }
     else if (VRTK_DeviceFinder.IsControllerRightHand(controller))
     {
         bow = VRTK_DeviceFinder.GetControllerLeftHand(true).GetComponentInChildren <BowAim>();
     }
     return(bow == null || !bow.HasArrow());
 }
Example #8
0
    void DoObjectGrab(object sender, InteractableObjectEventArgs e)
    {
        currentlyHeld = true;

        if (VRTK_DeviceFinder.IsControllerLeftHand(e.interactingObject))
        {
            controller = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_InteractGrab>();
        }
        else
        {
            controller = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_InteractGrab>();
        }
    }
Example #9
0
    protected override void OnHurt(int amount)
    {
        AkSoundEngine.PostEvent(akEventHurt, this.gameObject);
        UpdateHUD();

        GameObject Lcontroller = VRTK_DeviceFinder.GetControllerLeftHand();
        GameObject Rcontroller = VRTK_DeviceFinder.GetControllerRightHand();
        VRTK_ControllerReference LcontrollerReference = VRTK_ControllerReference.GetControllerReference(Lcontroller);
        VRTK_ControllerReference RcontrollerReference = VRTK_ControllerReference.GetControllerReference(Rcontroller);

        VRTK_ControllerHaptics.TriggerHapticPulse(LcontrollerReference, haptic_strength, haptic_duration, 0.005f);
        VRTK_ControllerHaptics.TriggerHapticPulse(RcontrollerReference, haptic_strength, haptic_duration, 0.005f);
    }
Example #10
0
        private void VRTKLongBow_InteractableObjectUngrabbed(object sender, InteractableObjectEventArgs e)
        {
            isGrab = false;
            bowCollider.enabled = true;

            if (handType == SDK_BaseController.ControllerHand.Left)
            {
                VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_InteractGrab>().ForceRelease();
            }
            else
            {
                VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_InteractGrab>().ForceRelease();
            }
        }
 void Start()
 {
     LeftHandColliders  = VRTK_DeviceFinder.GetControllerLeftHand().gameObject.transform.GetChild(0).GetChild(2).gameObject;
     RightHandColliders = VRTK_DeviceFinder.GetControllerRightHand().gameObject.transform.GetChild(0).GetChild(2).gameObject;
     backpack           = gameObject.AddComponent <BoxCollider>();
     backpack.size      = new Vector3(2.303633f, 2.189791f, 0.4338804f);
     backpack.center    = new Vector3(0.02300131f, -0.2983266f, -0.05426104f);
     backpack.isTrigger = true;
     backZone           = gameObject.GetComponent <VRTK_SnapDropZone>();
     backpackFull       = false;
     lefthandEntered    = false;
     righthandEntered   = false;
     notDisabled        = true;
 }
    public override void Highlight()
    {
        highlighterR = rightHand ? FetchHighlighter(VRTK_DeviceFinder.GetControllerRightHand()) : null;
        highlighterL = leftHand ? FetchHighlighter(VRTK_DeviceFinder.GetControllerLeftHand()) : null;

        if (highlighterR != null)
        {
            Highlight(highlighterR);
        }
        if (highlighterL != null)
        {
            Highlight(highlighterL);
        }
    }
    public override void Grabbed(VRTK_InteractGrab grabbingObject)
    {
        base.Grabbed(grabbingObject);

        if (VRTK_DeviceFinder.GetControllerLeftHand() == grabbingObject.gameObject)
        {
            VRMeleeManager.Inctance.SetLeftWeapon(gameObject);
        }

        if (VRTK_DeviceFinder.GetControllerRightHand() == grabbingObject.gameObject)
        {
            VRMeleeManager.Inctance.SetRightWeapon(gameObject);
        }
    }
        private void DoButtonOnePressed(object sender, ControllerInteractionEventArgs e)
        {
            DebugLogger(e.controllerIndex, "BUTTON ONE", "pressed down", e);
            // now instantiate a cube in my hand
            if (VRTK_DeviceFinder.GetControllerLeftHand(false) == VRTK_DeviceFinder.GetControllerByIndex(e.controllerIndex, false))
            {
                Debug.Log("left hand, dave");
            }



            GameObject leftHand = GameObject.Find("LeftController");
            GameObject block    = (GameObject)Instantiate(go, VRTK_DeviceFinder.GetControllerByIndex(e.controllerIndex, false).transform.position, Quaternion.identity);
        }
Example #15
0
    private void Awake()
    {
        _objectConfigModule   = ModuleManager.Instance.Get <ObjectsConfigModule>();
        _assemblyObjectModule = ModuleManager.Instance.Get <AssemblyObjectsModule>();

        _leftGrab  = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_InteractGrab>();
        _rightGrab = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_InteractGrab>();
        string name = gameObject.name.Replace("(Clone)", "");

        _id = _objectConfigModule.GetObjectInfoIDByName(name);
        _assemblyObjectModule.RegisterAssemblyObjectTransform(_id, transform);
        _jsonAssemblyObject = _assemblyObjectModule.GetJsonAssemblyObjectByID(_id);
        InitialChildPos(out _ID_HasPos_List);
    }
Example #16
0
    public void Highlight()
    {
        tooltipsR = rightHand ? FetchHighlighter(VRTK_DeviceFinder.GetControllerRightHand()) : null;
        tooltipsL = leftHand ? FetchHighlighter(VRTK_DeviceFinder.GetControllerLeftHand()) : null;

        if (tooltipsR != null)
        {
            Highlight(tooltipsR);
        }
        if (tooltipsL != null)
        {
            Highlight(tooltipsL);
        }
    }
Example #17
0
 private void DoObjectGrab(object sender, InteractableObjectEventArgs e)
 {
     if (VRTK_DeviceFinder.IsControllerLeftHand(e.interactingObject))
     {
         holdControl   = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_InteractGrab>();
         stringControl = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_InteractGrab>();
     }
     else
     {
         stringControl = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_InteractGrab>();
         holdControl   = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_InteractGrab>();
     }
     StartCoroutine("GetBaseRotation");
 }
Example #18
0
    private void CheckDevices()
    {
        GameObject leftController  = VRTK_DeviceFinder.GetControllerLeftHand();
        GameObject rightController = VRTK_DeviceFinder.GetControllerRightHand();

        if (leftController.activeSelf && rightController.activeSelf)
        {
            EventBus.Post(new SceneReadyEvent());
        }
        else
        {
            Invoke("CheckDevices", 1);
        }
    }
        protected override void OnEnable()
        {
            trackedObjects = new List <Transform>();
            movementList   = new Dictionary <Transform, List <float> >();
            //base.previousYPositions = new Dictionary<Transform, float>();
            previousTriggerAxisPositions = new Dictionary <Transform, float>();
            initalGaze        = Vector3.zero;
            direction         = Vector3.zero;
            previousDirection = Vector3.zero;
            averagePeriod     = 60;
            currentSpeed      = 0f;
            active            = false;

            activeMovement       = false;
            previousEngageButton = engageButton;

            bodyPhysics         = (bodyPhysics != null ? bodyPhysics : GetComponentInChildren <VRTK_BodyPhysics>());
            controllerLeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
            controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand();

            SetControllerListeners(controllerLeftHand, leftController, ref leftSubscribed);
            SetControllerListeners(controllerRightHand, rightController, ref rightSubscribed);

            headset = VRTK_DeviceFinder.HeadsetTransform();

            SetControlOptions(myControlOptions);

            playArea = VRTK_DeviceFinder.PlayAreaTransform();

            for (int i = 0; i < trackedObjects.Count; i++)
            {
                Transform trackedObj = trackedObjects[i];
                movementList.Add(trackedObj, new List <float>());
                if (isAxisYTheTriggerAxis)
                {
                    previousTriggerAxisPositions.Add(trackedObj, trackedObj.transform.localPosition.y);
                }
                else
                {
                    previousTriggerAxisPositions.Add(trackedObj, trackedObj.transform.localPosition.z);
                }
            }
            if (playArea == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.SDK_OBJECT_NOT_FOUND, "PlayArea", "Boundaries SDK"));
            }

            userUpVector = trackerPelvis.transform.up;
        }
Example #20
0
    public Vector3 Centre()
    {
        GameObject controllerHand;

        if (side == HandSide.Right)
        {
            controllerHand = VRTK_DeviceFinder.GetControllerRightHand(true);
        }
        else
        {
            controllerHand = VRTK_DeviceFinder.GetControllerLeftHand(true);
        }

        return(TargetTransform(ControllerTransform(controllerHand)).position);
    }
Example #21
0
 private void Start()
 {
     head             = VRTK_DeviceFinder.HeadsetTransform();
     leftHand         = VRTK_DeviceFinder.GetControllerLeftHand();
     rightHand        = VRTK_DeviceFinder.GetControllerRightHand();
     controllerEvents = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
     if (controllerEvents == null)
     {
         Debug.Log("Cannot find controller events script in Parent");
     }
     else
     {
         Debug.Log("Found controller events script in Parent");
     }
 }
Example #22
0
    void Start()
    {
        var leftHand  = VRTK_DeviceFinder.GetControllerLeftHand();
        var rightHand = VRTK_DeviceFinder.GetControllerRightHand();

        InitDestinationSetListener(leftHand, true);
        InitDestinationSetListener(rightHand, true);
        foreach (var destinationMarker in VRTK_ObjectCache.registeredDestinationMarkers)
        {
            if (destinationMarker.gameObject != leftHand && destinationMarker.gameObject != rightHand)
            {
                InitDestinationSetListener(destinationMarker.gameObject, true);
            }
        }
    }
Example #23
0
    private bool NoLightningAttached(GameObject controller)
    {
        if (VRTK_DeviceFinder.IsControllerLeftHand(controller))
        {
            GameObject controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand(true);
            controllerRightHand.transform.Find("LightningBoltClone");
        }
        else if (VRTK_DeviceFinder.IsControllerRightHand(controller))
        {
            GameObject controllerLeftHand = VRTK_DeviceFinder.GetControllerLeftHand(true);
            controllerLeftHand.transform.Find("LightningBoltClone");
        }

        return(bow == null || !bow.HasArrow());
    }
 private void Awake()
 {
     if (leftInteractGrab == null)
     {
         leftInteractGrab = VRTK_DeviceFinder.GetControllerLeftHand().GetComponent <VRTK_InteractGrab>();
     }
     if (rightInteractGrab == null)
     {
         rightInteractGrab = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <VRTK_InteractGrab>();
     }
     if (rangedInteractions == null)
     {
         rangedInteractions = VRTK_DeviceFinder.GetControllerRightHand().GetComponent <RangedInteractions>();
     }
 }
Example #25
0
    // Use this for initialization
    void Start()
    {
        restDarboux = new Quaternion(0.7f, 0.0f, 0.0f, 0.7f);       // constant
        offset      = new Vector3(0.2f, -1.0f, -0.3f);
        offsetNeg   = new Vector3(-0.2f, -1.0f, -0.3f);

        leftController  = VRTK_DeviceFinder.GetControllerLeftHand();
        rightController = VRTK_DeviceFinder.GetControllerRightHand();
        leftHandler     = GameObject.Find("left_hand");
        rightHandler    = GameObject.Find("right_hand");
        tapeSection     = GameObject.Find("clothPart");
        obiCloth        = tapeSection.GetComponent <ObiCloth>();

        leftCollider  = leftHandler.GetComponent <ObiCollider>();
        rightCollider = rightHandler.GetComponent <ObiCollider>();

        hint = GameObject.FindGameObjectsWithTag("Hint");

        audioHint[0] = false;
        audioHint[1] = false;
        audioHint[2] = false;
        audioHint[3] = false;

        stickPos[0] = GameObject.Find("StickPos_1");
        stickPos[1] = GameObject.Find("StickPos_2");
        stickPos[2] = GameObject.Find("StickPos_3");
        stickPos[3] = GameObject.Find("StickPos_4");

        foreach (var item in hint)
        {
            ParticleSystem particleSystem = item.GetComponent <ParticleSystem>();
            if (!particleSystem.isStopped)
            {
                particleSystem.Stop();
            }
        }

        Debug.Log("current part: " + StaticData.getTargetNum());

        string leftPath = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (left)/Model";

        rightHighlighter = GameObject.Find(leftPath).GetComponent <VRTK_ControllerHighlighter>();
        string rightPath = "[VRTK_SDKManager]/SDKSetups/SteamVR/[CameraRig]/Controller (right)/Model";

        rightHighlighter = GameObject.Find(rightPath).GetComponent <VRTK_ControllerHighlighter>();
    }
Example #26
0
    private void DoMove()
    {
        moveTrans = hitObj.target; // set moved object for later reference even when target is out
        if (!moved && !pulledDown)
        {
            moveObjOriPos = moveTrans.position; // set starting position to return to
        }

        Vector3 moveObjPos      = moveTrans.position;
        float   controllerYMove = VRTK_DeviceFinder.GetControllerLeftHand(true).transform.position.y - lastControllerPos.y;

        if (controllerYMove < 0)
        {
            moveObjPos.y      += controllerYMove * 5f;
            moveTrans.position = moveObjPos;
        }
        lastControllerPos = VRTK_DeviceFinder.GetControllerLeftHand(true).transform.position;
    }
Example #27
0
 bool Find()
 {
     if (findReady)
     {
         return(true);
     }
     playAreaTransform = VRTK_DeviceFinder.PlayAreaTransform();
     headsetTransform  = VRTK_DeviceFinder.HeadsetTransform();
     leftController    = VRTK_DeviceFinder.GetControllerLeftHand();
     rightController   = VRTK_DeviceFinder.GetControllerRightHand();
     findReady         = playAreaTransform && headsetTransform && leftController &&
                         rightController;
     if (findReady)
     {
         OnFindReady();
     }
     return(findReady);
 }
Example #28
0
    public void OnPlaceChair(int id)
    {
        Transform trackedObj = VRTK_DeviceFinder.GetControllerLeftHand().transform.parent;

        RaycastHit hit;
        bool       rayHit = Physics.Raycast(trackedObj.transform.position, trackedObj.transform.forward, out hit, 100);

        Vector3 middle = new Vector3(0.0f, 0.0f, 0.0f);

        if (rayHit && hit.collider.gameObject.tag.Contains("Floor"))
        {
            middle = hit.transform.position;

            GameObject newChair = Instantiate(chairsList[id], new Vector3(middle.x, middle.y, middle.z), Quaternion.Euler(new Vector3(-90.0f, 0.0f, -90.0f)), chairs.transform) as GameObject;
        }

        ReturnToPlaceFurnitureMenu();
    }
Example #29
0
    IEnumerator getControllers()
    {
        GameObject lgo = null;
        GameObject rgo = null;

        while (lgo == null && rgo == null)
        {
            lgo = VRTK_DeviceFinder.GetControllerLeftHand();
            rgo = VRTK_DeviceFinder.GetControllerRightHand();
            yield return(null);
        }
        leftController  = lgo.GetComponent <VRTK_ControllerEvents> ();
        rightController = rgo.GetComponent <VRTK_ControllerEvents> ();
        leftController.TouchpadPressed   += StartMoving;
        rightController.TouchpadPressed  += StartMoving;
        leftController.TouchpadReleased  += StopMoving;
        rightController.TouchpadReleased += StopMoving;
    }
    private IEnumerator FindDevices()
    {
        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        RightHand = VRTK_DeviceFinder.GetControllerRightHand();
        LeftHand  = VRTK_DeviceFinder.GetControllerLeftHand();

        RightHand.GetComponent <VRTK_ControllerEvents>().GripPressed       += RightHand_GripPressed;
        LeftHand.GetComponent <VRTK_ControllerEvents>().GripPressed        += LeftHand_GripPressed;
        RightHand.GetComponent <VRTK_ControllerEvents>().GripReleased      += DeSpawn;
        LeftHand.GetComponent <VRTK_ControllerEvents>().GripReleased       += DeSpawn;
        RightHand.GetComponent <VRTK_ControllerEvents>().StartMenuPressed  += DeSpawn;
        LeftHand.GetComponent <VRTK_ControllerEvents>().StartMenuPressed   += DeSpawn;
        RightHand.GetComponent <VRTK_ControllerEvents>().StartMenuReleased += DeSpawn;
        LeftHand.GetComponent <VRTK_ControllerEvents>().StartMenuReleased  += DeSpawn;
    }