Example #1
0
 private void SpawnObjectInHand(NVRHand hand)
 {
     if (hand.Inputs[NVRButtons.Grip].PressDown)
     {
         if (inevtoryController.RemovefromInventory(typeToRemove))
         {
             Debug.Log("Successfully removed item");
             //Spawn an object and make the hand interact with it
             GameObject       spawnedObject = (GameObject)Instantiate(prefabToSpawn, transform.position, transform.rotation);
             ExplosionEnabler rocket        = prefabToSpawn.GetComponent <ExplosionEnabler>();
             if (rocket)
             {
                 rocket.playerHealth = leftHand.GetComponent <HealthBarController>();
             }
             Medicine med = prefabToSpawn.GetComponent <Medicine>();
             if (med)
             {
                 Debug.Log("Spawned Medicine in hand");
                 med.health = leftHand.GetComponent <HealthBarController>();
                 med.head   = GameObject.Find("Head").GetComponent <NVRHead>();
             }
             PickableItem item = spawnedObject.GetComponent <PickableItem>();
             if (item != null)
             {
                 hand.BeginInteraction(item);
                 //TODO: Remove velocity
                 item.gameObject.GetComponent <Rigidbody>().velocity = new Vector3(0.0f, 0.0f, 0.0f);
             }
             else
             {
                 hand.BeginInteraction(spawnedObject.GetComponent <NVRExampleGun>());
             }
         }
     }
 }
Example #2
0
    public override void BeginInteraction(NVRHand hand)
    {
        base.BeginInteraction(hand);

        player = hand.Player;

        customHand = hand.GetComponent <CustomNVRHand>();
        customHand.terraformController.enabled = true;

        customHand.terraformController.SetObjectType(objectType);

        if (objectType == TerrainObjectType.Cell)
        {
            customHand.terraformController.SetCellType(cellType);
        }
    }
Example #3
0
    //Adds one NVRHand as a controller for the Vive Teleporter
    void Start()
    {
        teleporterScript = gameObject.GetComponent <TeleportVive>();

        if (teleporterScript != null)
        {
            if (nvrHand != null)
            {
                teleporterScript.Controllers    = new SteamVR_TrackedObject[1];
                teleporterScript.Controllers[0] = nvrHand.GetComponent <SteamVR_TrackedObject>();
                Debug.Log("Controller added as teleporter");
            }
            else
            {
                Debug.LogError("No NVRHand set in SteamVRControllerAdder");
            }
        }
        else
        {
            Debug.LogError("No Vive Teleporter attached to SteamVRControllerAdder");
        }
    }