示例#1
0
    void OnTriggerEnter(Collider col)
    {
        Valve.VR.InteractionSystem.Hand hand = null;
        Transform p = col.transform.parent;

        if (p != null)
        {
            hand = p.GetComponent <Valve.VR.InteractionSystem.Hand>();

            if (hand == null)
            {
                while (p.parent != null)
                {
                    if (p.parent.GetComponent <Valve.VR.InteractionSystem.Hand>() != null)
                    {
                        hand = p.parent.GetComponent <Valve.VR.InteractionSystem.Hand>();
                        break;
                    }

                    p = p.parent;
                }
            }
        }

        if (hand != null)
        {
            col.GetComponent <Valve.VR.InteractionSystem.Throwable>().enabled = false;
            col.GetComponent <Rigidbody>().isKinematic = false;
            hand.DetachAllObjects();
        }
    }
示例#2
0
    //-------------------------------------------------
    // Called every Update() while a Hand is hovering over this object
    //-------------------------------------------------
    private void HandHoverUpdate(ValveVR.Hand hand)
    {
        ValveVR.GrabTypes startingGrabType = hand.GetGrabStarting();
        bool isGrabEnding = hand.IsGrabEnding(this.gameObject);

        if (interactable.attachedToHand == null && startingGrabType != ValveVR.GrabTypes.None)
        {
            // Save our position/rotation so that we can restore it when we detach
            //oldPosition = transform.position;
            //oldRotation = transform.rotation;

            // Call this to continue receiving HandHoverUpdate messages,
            // and prevent the hand from hovering over anything else
            hand.HoverLock(interactable);

            // Attach this object to the hand
            hand.AttachObject(gameObject, startingGrabType, attachmentFlags);
        }
        else if (isGrabEnding)
        {
            // Detach this object from the hand
            hand.DetachObject(gameObject);

            // Call this to undo HoverLock
            hand.HoverUnlock(interactable);

            // Restore position/rotation
            //transform.position = oldPosition;
            //transform.rotation = oldRotation;
        }
    }
示例#3
0
    public void ReceiveCollision(GameObject other)
    {
        if (ballHeldType == -1)
        {
            // Get information about this ball.
            timeStartedHolding = Time.time;

            ballHeld = other;

            Valve.VR.InteractionSystem.Hand hand = GetComponent <Valve.VR.InteractionSystem.PrismInteractable>().activeHand;

            hand.controller.TriggerHapticPulse(hapticDuration);

            ballHeldType = ballHeld.GetComponent <Ball>().ballType;
            // prismLens.GetComponent<Renderer>().sharedMaterial = BallManager.instance.ballTypes[ballHeldType].material;

            ballHeld.GetComponent <Ball>().ballIsHeld         = true;
            ballHeld.GetComponent <BallMovement>().stopMoving = true;
            ballHeld.transform.parent   = prismLens.transform;
            ballHeld.transform.position = prismLens.transform.position;

            PrismManager.instance.PrismReceivedBall();
            // Destroy(other);
        }
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        _hand = GetComponent <Valve.VR.InteractionSystem.Hand>();


        l.SetRange(range);
    }
示例#5
0
 public void InteractSlot(Valve.VR.InteractionSystem.Hand hand)
 {
     if (!slot)
     {
         slot.StartInteraction(hand);
     }
 }
示例#6
0
    private void Awake()
    {
        m_LineRenderer = GetComponent <LineRenderer>();

        GameObject R_hand = this.transform.parent.gameObject;

        m_Hand = R_hand.GetComponent <Valve.VR.InteractionSystem.Hand>();
    }
    void Start()
    {
        hand = GetComponentInParent <Valve.VR.InteractionSystem.Hand>();
        //if (hand.startingHandType == Valve.VR.InteractionSystem.Hand.HandType.Left)
        //    transform.localScale = new Vector3(-1, 1, 1);

        anim = GetComponent <Animator>();
    }
 // Use this for initialization
 private void Start()
 {
     handScript   = this.GetComponent <Valve.VR.InteractionSystem.Hand>();
     cBScript     = canvas.GetComponent <CodeBlueScript>();
     latex        = Resources.Load("latex") as Texture;
     skin         = Resources.Load("FemaleMedium") as Texture;
     buttonPushed = false;
 }
示例#9
0
    // Use this for initialization
    void Start()
    {
        //leftController = GetComponent<Hand>()
        //Debug.Log("Look out Below");
        //Debug.Log(GetComponent<Hand>());

        leftController = gameObject.GetComponent <Valve.VR.InteractionSystem.Hand>();
        Debug.Log(leftController);
    }
示例#10
0
    public override void OnSelected(Valve.VR.InteractionSystem.Hand hand)
    {
        ShowRadialMenu();
        var rm = GetMyRadialMenu;
        rm.top.AddFunctionOnPress(delegate { SetTypeTarget(EnemyTypes.Rifle); });
        rm.right.AddFunctionOnPress(delegate { SetTypeTarget(EnemyTypes.Sniper); });



    }
示例#11
0
    /* private void Start()
     * {
     *   MeshRenderer[] ms = GetComponentsInChildren<MeshRenderer>();
     *   foreach (var m in ms)
     *   {
     *       defaultColors.Add(m.material.color);
     *   }
     *   mr = GetComponentInChildren<SkinnedMeshRenderer>();
     *   base.Start();
     * }
     * public void ChangeColor(Color color)
     * {
     *   MeshRenderer[] ms = GetComponentsInChildren<MeshRenderer>();
     *   foreach (var m in ms)
     *   {
     *       m.material.color = color;
     *   }
     * }
     * public void ChangeSpecificColor(Color color)
     * {
     *   mr.materials[8].color = color;
     * }
     *
     * public void ResetSpecificColor()
     * {
     *   mr.materials[8].color = Color.yellow;
     * }
     *
     * public void ResetColors()
     * {
     *   MeshRenderer[] ms = GetComponentsInChildren<MeshRenderer>();
     *
     *   for (int i = 0; i < defaultColors.Count; i++)
     *   {
     *       ms[i].material.color = defaultColors[i];
     *   }
     * }
     */

    public override void OnSelected(Valve.VR.InteractionSystem.Hand hand)
    {
        base.OnSelected(hand);
        //ChangeSpecificColor(Color.green);
        var rm = GetMyRadialMenu;

        rm.top.AddFunctionOnPress(Incarnated);
        rm.left.AddFunctionOnPress(MoveTowards);
        //rm.right.AddFunctionOnPress(SetPrioirityPoint());
        //rm.
    }
示例#12
0
    private void OnEnable()
    {
        _scaleController    = init.scaleController;
        _trackedController2 = inputManager.trackedController2;
        _rotationGizmos     = init.rotationGizmos;
        _vrCamera           = init.vrCamera;
        _hand2 = inputManager.hand2;

        _trackedController2.TriggerClicked += triggerClicked;
        _scaleController.SetActive(true);
    }
示例#13
0
    private void OnEnable()
    {
        if (Hand == null)
        {
            Hand = GetComponent <Valve.VR.InteractionSystem.Hand>();
        }

        Debug.Assert(Action != null, "No action assigned");

        Action.AddOnUpdateListener(OnSingleUpdate, Hand.handType);
    }
示例#14
0
    private void OnEnable()
    {
        if (Hand == null)
        {
            Hand = GetComponent <Valve.VR.InteractionSystem.Hand>();
        }

        Debug.Assert(Action != null, "No action assigned");

        mPlayer = GameObject.Find("Player").transform;

        Action.AddOnUpdateListener(OnVector2Update, Hand.handType);
    }
    private Valve.VR.InteractionSystem.Hand GetParentHand(GameObject child)
    {
        Valve.VR.InteractionSystem.Hand hand = child.GetComponent <Valve.VR.InteractionSystem.Hand>();

        if (hand == null)
        {
            return(GetParentHand(child.transform.parent.gameObject));
        }
        else
        {
            return(hand);
        }
    }
示例#16
0
    // Use this for initializati 'on
    void Start()
    {
        trackedObj = gameObject.GetComponent <SteamVR_TrackedObject>();
        Debug.Log((int)trackedObj.index);
        hand       = gameObject.GetComponent <Hand>();
        controller = hand.controller;


        /* if (hand.controller == null)
         * {
         *   Debug.Log("Controller not initilized");
         *   return;
         * }*/
    }
示例#17
0
    IEnumerator ChangeColorRoutine(Valve.VR.InteractionSystem.Hand hand)
    {
        _audioSource.loop = true;
        _audioSource.clip = ItemSpinSound;
        _audioSource.Play();

        while (hand.currentAttachedObject == gameObject)
        {
            var randColor = Random.ColorHSV();
            yield return(new WaitForSeconds(0.05f));

            GetComponent <MeshRenderer>().material.color = randColor;
            yield return(null);
        }
    }
示例#18
0
    private void Awake()
    {
        //Match up the hardware index with the "steamVR Hand2"
        //So the Hand2 is always the starting rightmost hand reletive to the HMD
        //Not sure why steamVR's select hand option doesn't do this, let me know if you figure it out
        hand1 = GameObject.Find("Hand1").GetComponent <Valve.VR.InteractionSystem.Hand>();
        hand2 = GameObject.Find("Hand2").GetComponent <Valve.VR.InteractionSystem.Hand>();
        trackedController1 = hand1.gameObject.GetComponent <SteamVR_TrackedController>();
        trackedController2 = hand2.gameObject.GetComponent <SteamVR_TrackedController>();
        trackedObject2     = hand2.GetComponent <SteamVR_TrackedObject>();
        selectorHand       = SteamVR_Controller.Input((int)trackedObject2.index);

        //This method depends on another steamVR method which fires 1s after the app starts.
        //The steamVR method finds the hardware indecies of the controllers
        Invoke("setControllerIndecies", 1.2f);
    }
示例#19
0
    void Start()
    {
        _stateManagerMutatorRef = init._stateManagerMutatorRef;
        _trackedController2     = inputManager.trackedController2;
        _hand2 = inputManager.hand2;

        //--Gets reparented in the selector hand and set to the hands position
        transform.parent        = _hand2.transform;
        transform.localPosition = Vector3.zero;

        _trackedController2.PadTouched   += padTouched;
        _trackedController2.PadUntouched += padUntouched;

        stateManager.selectedObjectIsActiveEvent  += updateSelectedObjectIsActive;
        stateManager.rotationGizmoIsSelectedEvent += updateRotationGizmoIsSelected;
    }
示例#20
0
    // Use this for initialization
    void Start()
    {
        gunEnd      = gameObject.transform;
        AudioSource = GetComponent <AudioSource>();
        trackedObj  = gameObject.GetComponent <SteamVR_TrackedObject>();

        hand = GetComponent <Hand>();
        //controller = hand.controller;
        AudioSource  = GetComponent <AudioSource>();
        lineRenderer = GetComponent <LineRenderer>();

        /*if (hand.controller == null)
         * {
         *  Debug.Log("Controller not initilized");
         *  return;
         * }*/
    }
示例#21
0
        // Use this for initialization
        void Start()
        {
            hand               = GetComponent <ValveIS.Hand>();
            layerMask          = 1 << LayerMask.NameToLayer("InteractionSystemLayer");
            handHoverTransform = hand.hoverSphereTransform;
            initialLocalPosHT  = handHoverTransform.localPosition;

            #region init laserbeam
            beamObj = GameObject.CreatePrimitive(PrimitiveType.Cube);
            beamObj.GetComponent <MeshRenderer>().sharedMaterial = laserMaterial;
            beamObj.name = "LaserBeam";
            beamObj.transform.SetParent(hand.transform);
            beamObj.transform.localRotation = Quaternion.identity;
            beamObj.transform.localPosition = Vector3.zero;
            beamObj.transform.localScale    = new Vector3(laserThickness, laserThickness, 1f);
            beamObj.SetActive(false);
            #endregion
        }
    void Start()
    {
        // Leg die LineRenderer Komponente unter laser ab und setze die zweite Koordinate vom LineRenderer auf die
        // einstellbare Distanz, konkreter auf (0,0,Distanz). Die erste Koordinate (Index 0) ist bei (0,0,0)


        GameObject handRight = GameObject.Find("Hand1");

        if (handRight != null)
        {
            scannerHand = handRight.GetComponent <Valve.VR.InteractionSystem.Hand>();
            scanner     = scannerHand.transform;
        }
        laser = scanner.GetComponent <LineRenderer>();
        laser.SetPosition(1, scanner.forward * lineRendererDistance);
        canScan             = true;
        scannerDisplay.text = "-";
    }
示例#23
0
    IEnumerator RetrieveRightHand()
    {
        while (rController == null)
        {
            Transform hand = GetComponent <NetFollow>().src_rHand;
            if (hand)
            {
                GameObject r = hand.gameObject;
                if (r)
                {
                    rController = r.GetComponent <Valve.VR.InteractionSystem.Hand>();
                }

                yield return(new WaitForEndOfFrame());
            }
        }

        foundRight = true;
    }
示例#24
0
    /*
     *  void grab()
     *  {
     *  if (Input.GetMouseButtonDown (1))
     *          {
     *                  click = !click;
     *                  controller.SetBool("IsGrabing",click);
     *          }
     *  }
     */

    IEnumerator RetrieveLeftHand()
    {
        while (lController == null)
        {
            Transform hand = GetComponent <NetFollow>().src_lHand;
            if (hand)
            {
                GameObject l = hand.gameObject;
                if (l)
                {
                    lController = l.GetComponent <Valve.VR.InteractionSystem.Hand>();
                }

                yield return(new WaitForEndOfFrame());
            }
        }

        foundLeft = true;
    }
示例#25
0
    public void disableComponentsForWaiting()
    {
        // Detach the pill from the hand holding it
        Valve.VR.InteractionSystem.Hand handHoldingPill = simManagerComponent.getHandScriptHoldingObj(waitPill);
        if (handHoldingPill != null)
        {
            handHoldingPill.DetachObject(waitPill);
        }

        justWait = true;
        waitBucketPlatform.SetActive(true);
        payPanel.SetActive(false);
        payPill.SetActive(false);
        waitPill.SetActive(false);
        payPedestal.SetActive(false);
        waitPedestal.SetActive(false);
        treatmentInformationPanel.SetActive(false);
        payBottlePositionA  = new Vector3(NULL_POS, NULL_POS, NULL_POS);
        payBottlePositionB  = new Vector3(NULL_POS, NULL_POS, NULL_POS);
        waitBottlePositionA = new Vector3(NULL_POS, NULL_POS, NULL_POS);
        waitBottlePositionB = new Vector3(NULL_POS, NULL_POS, NULL_POS);
    }
示例#26
0
    private void OnDetachedFromHand(ValveVR.Hand hand)
    {
        float goal_x = goal.transform.position.x;
        float goal_y = goal.transform.position.y;
        float goal_z = goal.transform.position.z;


        if (Mathf.Abs(transform.position.x - goal_x) < MAX_DIFF)
        {
            if (Mathf.Abs(transform.position.y - goal_y) < MAX_DIFF)
            {
                if (Mathf.Abs(transform.position.z - goal_z) < MAX_DIFF)
                {
                    textMesh.text = "Good!";
                }
            }
        }
        else
        {
            textMesh.text = "";
        }
    }
示例#27
0
 public override void OnSelected(Valve.VR.InteractionSystem.Hand hand)
 {
     // Show Info
     // Show Options
     ShowRadialMenu();
 }
示例#28
0
 public void MakeGlow(Valve.VR.InteractionSystem.Hand hand)
 {
 }
示例#29
0
    /*
     * Attempt to make a transaction - validate that the participant
     * can afford it, and then call out as necessary to apply changes
     * to the environment to reflect the transaction.
     */
    private bool attemptObtain(TreatmentObtainType t)
    {
        float effectiveWaitTime = -1.0f;     // Seconds
        float effectiveCost     = -1.0f;     // Lab dollars
        bool  transactionValid  = false;

        SimManager.GameState currentSimState = simManagerComponent.currentState();

        if (t == TreatmentObtainType.PAY)
        {
            effectiveCost    = simManagerComponent.getCurrentTreatmentCost();
            transactionValid = (
                currentSimState == SimManager.GameState.RUNNING &&
                simManagerComponent.getCurrentScore() > effectiveCost
                );
        }

        else if (t == TreatmentObtainType.WAIT)
        {
            effectiveWaitTime = simManagerComponent.getCurrentTreatmentWaitTime();
            transactionValid  = currentSimState == SimManager.GameState.RUNNING;
        }


        // Only apply changes to the environment if the transaction was approved
        if (transactionValid)
        {
            if (t != TreatmentObtainType.WAIT)
            {
                disablePanels();
            }
            simManagerComponent.determinePostTreatmentActions(t, effectiveCost, effectiveWaitTime);
        }

        else
        {
            // Play a quick error sound to make them realize it didn't work
            audioManagerComponent.playSound(AudioManager.SoundType.ERROR);

            Debug.Log("Invalid treatment obtain attempt. Resetting " + t.ToString() + " bottle position.");

            if (t == TreatmentObtainType.PAY)
            {
                // Detach the pill from the hand holding it
                Valve.VR.InteractionSystem.Hand handHoldingPill = simManagerComponent.getHandScriptHoldingObj(payPill);
                if (handHoldingPill != null)
                {
                    handHoldingPill.DetachObject(payPill);
                }

                // Then, reset its position
                payPill.transform.position = new Vector3(
                    payBottleInitXPosition,
                    payBottleInitYPosition,
                    payBottleInitZPosition
                    ); payPill.transform.eulerAngles = new Vector3(0.0f, 0.0f, 0.0f);

                payBottlePositionA = payPill.transform.position;
            }

            else if (t == TreatmentObtainType.WAIT)
            {
                // Detach the pill from the hand holding it
                Valve.VR.InteractionSystem.Hand handHoldingPill = simManagerComponent.getHandScriptHoldingObj(waitPill);
                if (handHoldingPill != null)
                {
                    handHoldingPill.DetachObject(waitPill);
                }

                // Then, reset its position
                waitPill.transform.position = new Vector3(
                    waitBottleInitXPosition,
                    waitBottleInitYPosition,
                    waitBottleInitZPosition
                    ); waitPill.transform.eulerAngles = new Vector3(0.0f, 0.0f, 0.0f);

                waitBottlePositionA = waitPill.transform.position;
            }

            else
            {
                Debug.Log("Unrecognized bottle type. Not resetting position.");
            }
        }

        return(transactionValid);
    }
示例#30
0
 public void Start()
 {
     _valveHand = Hand1.GetComponent <VRIAS.Hand>();
 }