Exemplo n.º 1
0
    void Awake()
    {
        MakeSingleton();

        CurrentGameMode = GameMode.BUILD;

        /* Setup Controller Events */
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress, true, RightControllerEvents_TriggerDown);
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress, false, RightControllerEvents_TriggerUp);
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.GripPress, true, RightControllerEvents_GripDown);
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.GripPress, false, RightControllerEvents_GripUp);
        RightControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TouchpadPress, false, RightControllerEvents_TouchpadUp);

        LeftControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress, true, LeftControllerEvents_TriggerDown);
        LeftControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress, false, LeftControllerEvents_TriggerUp);
        LeftControllerEvents.SubscribeToButtonAliasEvent(VRTK.VRTK_ControllerEvents.ButtonAlias.GripPress, false, LeftControllerEvents_GripUp);

        /* Setup Controller VRTK scripts */
        VRTK.VRTK_InteractGrab rightInteractGrab = RightControllerEvents.GetComponent <VRTK.VRTK_InteractGrab>();
        rightInteractGrab.grabButton = VRTK.VRTK_ControllerEvents.ButtonAlias.TriggerPress;

        RightInteractNearTouch = RightControllerEvents.GetComponent <VRTK.VRTK_InteractNearTouch>();
        RightInteractTouch     = RightControllerEvents.GetComponent <VRTK.VRTK_InteractTouch>();
        RightInteractGrab      = RightControllerEvents.GetComponent <VRTK.VRTK_InteractGrab>();

        RightAnimator = RightControllerEvents.gameObject.GetComponentInChildren <HandAnimator>();
        LeftAnimator  = LeftControllerEvents.gameObject.GetComponentInChildren <HandAnimator>();
    }
 public override void Grabbed(VRTK.VRTK_InteractGrab currentGrabbingObject)
 {
     base.Grabbed(currentGrabbingObject);
     Debug.Log("Grabbed");
     controllerEvents = currentGrabbingObject.GetComponent <VRTK.VRTK_ControllerEvents>();
     shootAudio       = GetComponent <AudioSource> ();
 }
Exemplo n.º 3
0
 public override void Grabbed(VRTK.VRTK_InteractGrab currentGrabbingObject)
 {
     Debug.Log("Hello darkness my old friend");
     base.Grabbed(currentGrabbingObject);
     voiceOverAudio.Stop();
     voiceOverAudio.clip = youMakeLaughClip;
     voiceOverAudio.Play();
 }
 public override void Ungrabbed(VRTK.VRTK_InteractGrab previousGrabbingObject = null)
 {
     if (drawThrowLine)
     {
         UpdateLine();
     }
     base.Ungrabbed(previousGrabbingObject);
 }
 public override void Grabbed(VRTK.VRTK_InteractGrab currentGrabbingObject = null)
 {
     base.Grabbed(currentGrabbingObject);
     VRTK.VRTK_InteractUse iu = currentGrabbingObject.gameObject.GetComponent <VRTK.VRTK_InteractUse> ();
     if (iu == null)
     {
         iu = currentGrabbingObject.gameObject.AddComponent <VRTK.VRTK_InteractUse> ();
     }
 }
        private void Start()
        {
            controller = this.GetComponent<VRTK_InteractGrab>();
            initGrab = false;
            initGrabCooldown = 0.5f;

            if (!controller)
            {
                Debug.LogError("The VRTK_InteractGrab script is required to be attached to the controller along with this script.");
            }

            if (!objectToGrab || !objectToGrab.GetComponent<VRTK_InteractableObject>())
            {
                Debug.LogError("The objectToGrab Game Object must have the VRTK_InteractableObject script applied to it.");
            }
        }
        private IEnumerator AutoGrab()
        {
            controller = GetComponent<VRTK_InteractGrab>();
            if (!controller)
            {
                Debug.LogError("The VRTK_InteractGrab script is required to be attached to the controller along with this script.");
                yield break;
            }

            if (!objectToGrab)
            {
                Debug.LogError("You have to assign an object that should be grabbed.");
                yield break;
            }

            while (controller.controllerAttachPoint == null)
            {
                yield return true;
            }

            grabbableObject = objectToGrab;
            if (cloneGrabbedObject)
            {
                if (previousClonedObject == null)
                {
                    grabbableObject = Instantiate(objectToGrab);
                    previousClonedObject = grabbableObject;
                }
                else
                {
                    grabbableObject = previousClonedObject;
                }
            }

            if (grabbableObject.isGrabbable && !grabbableObject.IsGrabbed())
            {
                if (grabbableObject.AttachIsKinematicObject())
                {
                    grabbableObject.ToggleKinematic(true);
                }

                grabbableObject.transform.position = transform.position;
                controller.GetComponent<VRTK_InteractTouch>().ForceStopTouching();
                controller.GetComponent<VRTK_InteractTouch>().ForceTouch(grabbableObject.gameObject);
                controller.AttemptGrab();
            }
        }
 private bool CanGrab(VRTK_InteractGrab grabbingController)
 {
     return (grabbingController && grabbingController.GetGrabbedObject() == null && grabbingController.gameObject.GetComponent<VRTK_ControllerEvents>().grabPressed);
 }
Exemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     cEv     = GetComponent <VRTK.VRTK_ControllerEvents> ();
     grabber = GetComponent <VRTK.VRTK_InteractGrab> ();
     user    = GetComponent <VRTK.VRTK_InteractUse> ();
 }