Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- [RequireComponent(typeof(SteamVR_TrackedObject))]
- public class PickupParent : MonoBehaviour {
- SteamVR_TrackedObject trackedObj;
- void Awake () {
- trackedObj = GetComponent<SteamVR_TrackedObject>();
- }
- void Update () {
- SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);
- if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
- {
- Debug.Log("You are touching the trigger.");
- }
- if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
- {
- Debug.Log("You have touched the trigger.");
- }
- if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
- {
- Debug.Log("You have released the trigger.");
- }
- if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
- {
- Debug.Log("You are pressing the trigger.");
- }
- if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
- {
- Debug.Log("You have pressed the trigger.");
- }
- if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
- {
- Debug.Log("You have released the trigger press.");
- }
- }
- void OnTriggerStay (Collider col)
- {
- SteamVR_Controller.Device device = SteamVR_Controller.Input((int)trackedObj.index);
- Debug.Log("You have collided with " + col.name + " and activated OnTriggerStay.");
- if (device.GetTouch(SteamVR_Controller.ButtonMask.Trigger))
- {
- Debug.Log("You have collided with " + col.name + " while holding down Touch.");
- col.attachedRigidbody.isKinematic = true;
- col.gameObject.transform.SetParent(gameObject.transform);
- }
- if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
- {
- Debug.Log("You have released Touch while colliding with " + col.name);
- col.gameObject.transform.SetParent(null);
- col.attachedRigidbody.isKinematic = false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement