Example #1
0
    IEnumerator Start()
    {
        while (vrtk_manager.modelAliasLeftController.transform.Find("body") == null || vrtk_manager.modelAliasRightController.transform.Find("body") == null)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        leftInteractTouch       = vrtk_manager.scriptAliasLeftController.GetComponent <VRTK_InteractTouch> ();
        rightInteractTouch      = vrtk_manager.scriptAliasRightController.GetComponent <VRTK_InteractTouch> ();
        leftInteractUse         = vrtk_manager.scriptAliasLeftController.GetComponent <VRTK_InteractUse> ();
        rightInteractUse        = vrtk_manager.scriptAliasRightController.GetComponent <VRTK_InteractUse> ();
        rightControllerTooltips = vrtk_manager.scriptAliasRightController.GetComponentInChildren <VRTK_ControllerTooltips> ();
        leftControllerTooltips  = vrtk_manager.scriptAliasLeftController.GetComponentInChildren <VRTK_ControllerTooltips> ();

        playerInfoManager = FindObjectOfType <PlayerInfoManager> ();
        rightTeleporter   = vrtk_manager.scriptAliasRightController.transform.Find("Teleporter").gameObject;
        leftTeleporter    = vrtk_manager.scriptAliasLeftController.transform.Find("Teleporter").gameObject;

        FindObjectOfType <PlayerHealth> ().OnPlayerDied    += OnPlayerDied;
        FindObjectOfType <PlayerHealth> ().OnPlayerRevived += OnPlayerRevived;
        playerInfoManager.OnPlayerInfoViewOpened           += OnPlayerInfoOpenend;
        playerInfoManager.OnPlayerInfoViewClosed           += OnPlayerInfoClosed;

        SetOutfitterMode(OutfitterMode.EXPLORE);

        setupFinished = true;
    }
 private void SetInteractTouch()
 {
     if (it == null)
     {
         it = GetComponent <VRTK_InteractTouch>();
     }
 }
    private void SetupTouch(VRTK_InteractTouch touch, int index)
    {
        if (!touch)
        {
            Debug.LogError("No VRTK_InteractTouch given");
            return;
        }

        touch.ControllerStartTouchInteractableObject += (s, a) =>
        {
            var touching = controllersTouching[index];

            if (!touching.Contains(a.target) && !a.target.name.Contains("[NearTouch][CollidersContainer]"))
            {
                AddTouching(a.target, index);
            }
        };

        touch.ControllerStartUntouchInteractableObject += (s, a) =>
        {
            var touching = controllersTouching[index];

            if (touching.Contains(a.target))
            {
                RemoveTouching(a.target, index);
            }
        };
    }
Example #4
0
    public void OnEnable()
    {
        interactTouch = LController.GetComponent <VRTK_InteractTouch>();
        interactTouch.ControllerStartTouchInteractableObject += flowerTrigger;

        onFlower = false;
    }
 void InitVar()
 {
     m_pointer        = GetComponent <VRTK_Pointer>();
     m_playAreaCursor = GetComponent <VRTK_PlayAreaCursor>();
     m_interTouch     = GetComponent <VRTK_InteractTouch>();
     m_interGrab      = GetComponent <VRTK_InteractGrab>();
 }
Example #6
0
 public override void StopTouching(VRTK_InteractTouch previousTouchingObject = null)
 {
     Debug.Log("uncovered ear");
     covered = false;
     uncoveredEvent.Invoke();
     base.StopTouching(previousTouchingObject);
 }
 public override bool StartGrab(GameObject grabbingObject, GameObject givenGrabbedObject, Rigidbody givenControllerAttachPoint)
 {
     touch = grabbingObject.GetComponent <VRTK_InteractTouch>();
     grab  = grabbingObject.GetComponent <VRTK_InteractGrab>();
     StartCoroutine(ForceGrab());
     return(false);
 }
Example #8
0
 public override void StartTouching(VRTK_InteractTouch currentTouchingObject = null)
 {
     Debug.Log("covered ear");
     covered = true;
     coveredEvent.Invoke();
     base.StartTouching(currentTouchingObject);
 }
Example #9
0
    private IEnumerator SwapToObjectSequence()
    {
        _isSnappingToHand = false;
        _isSnappedToHand  = true;

        _proxy.SetActive(false);
        _actualObject.gameObject.SetActive(true);

        for (int i = 0; i < _actualObjectInteractables.Length; i++)
        {
            _actualObjectInteractables[i].InteractableObjectUngrabbed += HandleObjectDropped;
        }

        _bookImageCollider.enabled = false;

        _actualObject.transform.position = _proxy.transform.position;
        _actualObject.transform.rotation = _proxy.transform.rotation;
        _actualObject.transform.SetParent(null);

        VRTK_InteractTouch touch = _controllerReference.actual.GetComponentInChildren <VRTK_InteractTouch>();
        VRTK_InteractGrab  grab  = _controllerReference.actual.GetComponentInChildren <VRTK_InteractGrab>();

        if (_actualObjectInteractables.Length > 0)
        {
            touch.ForceTouch(_actualObjectInteractables[0].gameObject);
        }

        grab.ForceRelease();

        yield return(null);

        grab.AttemptGrab();
    }
Example #10
0
    private void GrabObject(Collider other)
    {
        if (_objectInfo == null)
        {
            return;
        }

        VRTK_InteractGrab grab = (other.GetComponent <VRTK_InteractGrab>() ? other.GetComponent <VRTK_InteractGrab>() : other.GetComponentInParent <VRTK_InteractGrab>());

        if (grab && grab.GetGrabbedObject() == null && grab.gameObject.GetComponent <VRTK_ControllerEvents>().grabPressed&& Time.time >= _grabTimer)
        {
            string             Name   = _objectInfo.EnglishName;
            VRTK_InteractTouch touch  = grab.gameObject.GetComponent <VRTK_InteractTouch>();
            GameObject         prefab = Instantiate(Resources.Load <GameObject>("Prefabs/LabObjects/" + Name), null, false);
            if (prefab == null)
            {
                Debug.LogError("The labObjects of name: " + Name + " is null!");
                return;
            }

            touch.ForceTouch(prefab);
            grab.AttemptGrab();
            _grabTimer = Time.time + _grabDelay;
        }
    }
Example #11
0
 private void InitVar()
 {
     m_VRplayRig           = GetComponentInParent <KaiTool_VRPlayerRig>();
     m_interTouch          = GetComponent <VRTK_InteractTouch>();
     m_interGrab           = GetComponent <VRTK_InteractGrab>();
     m_controllerReference = VRTK_ControllerReference.GetControllerReference(gameObject);
 }
Example #12
0
 public override void StartTouching(VRTK_InteractTouch interactTouch)
 {
     ResetHeart(30);
     base.StartTouching(interactTouch);
     GameController.playerHealth += 10;
     meshR.enabled   = false;
     sphereC.enabled = false;
 }
    // Use this for initialization
    void Start()
    {
        leftInteractGrab  = leftController.GetComponent <VRTK_InteractGrab>();
        rightInteractGrab = rightController.GetComponent <VRTK_InteractGrab>();

        leftTouch  = leftController.GetComponent <VRTK_InteractTouch>();
        rightTouch = rightController.GetComponent <VRTK_InteractTouch>();
    }
Example #14
0
 public override void StopTouching(VRTK_InteractTouch currentTouchingObject = null)
 {
     base.StopTouching(currentTouchingObject);
     if (onStopTouching != null)
     {
         onStopTouching.OnNext(currentTouchingObject);
     }
 }
 // Use this for initialization
 void Start()
 {
     controllerTag = gameObject.tag;
     if (controllerTag == "Untagged")
     {
         throw new Exception("you will need to set controllertags on the controller. use: controller1 and controller2");
     }
     controller = gameObject.GetComponent <VRTK_InteractTouch>();
 }
Example #16
0
 private void InitVar()
 {
     handAnimator    = handModel.GetComponent <Animator>();
     controllerEvent = GetComponent <VRTK_ControllerEvents>();
     interactTouch   = GetComponent <VRTK_InteractTouch>();
     interactGrab    = GetComponent <VRTK_InteractGrab>();
     interactUsed    = GetComponent <VRTK_InteractUse>();
     pointer         = GetComponent <VRTK_Pointer>();
 }
Example #17
0
    public AudioClip PickupSE;       // 撿起方塊的音效

    /// <summary>
    /// 自動抓取方塊
    /// </summary>
    /// <param name="currentTouchingObject"></param>
    public override void StartTouching(VRTK_InteractTouch currentTouchingObject = null)
    {
        //if (PickupSE != null && currentTouchingObject.gameObject.name == "LeftControllerScriptAlias")
        //GameAudioController.Instance.PlayOneShot(PickupSE);
        base.StartTouching(currentTouchingObject);
        VRTK_InteractGrab myGrab = currentTouchingObject.GetComponent <VRTK_InteractGrab>();

        myGrab.AttemptGrab();
    }
Example #18
0
    // Use this for initialization
    IEnumerator Start()
    {
        RightHandTouch = rightHand.GetComponent <VRTK_InteractTouch> ();
        RightHandGrab  = rightHand.GetComponent <VRTK_InteractGrab> ();

        LeftHandTouch = leftHand.GetComponent <VRTK_InteractTouch> ();
        LeftHandGrab  = leftHand.GetComponent <VRTK_InteractGrab> ();

        yield return(new WaitForSeconds(1));
    }
Example #19
0
    // Use this for initialization
    void Start()
    {
        RightHandTouch  = rightHand.GetComponent <VRTK_InteractTouch> ();
        RightHandGrab   = rightHand.GetComponent <VRTK_InteractGrab> ();
        RightHandEvents = rightHand.GetComponent <VRTK_ControllerEvents> ();
        LeftHandTouch   = leftHand.GetComponent <VRTK_InteractTouch> ();
        LeftHandGrab    = leftHand.GetComponent <VRTK_InteractGrab> ();

        RightHandEvents.TriggerPressed += new ControllerInteractionEventHandler(GrabSpear);
    }
 public override void StartTouching(VRTK_InteractTouch currentTouchingObject = null)
 {
     base.StartTouching(currentTouchingObject);
     if (AutoHoldOnGrab)
     {
         VRTK_InteractGrab myGrab = currentTouchingObject.GetComponent <VRTK_InteractGrab>();
         myGrab.AttemptGrab();
         // transform.localPosition = Vector3.zero;
     }
 }
Example #21
0
 public override void StartTouching(VRTK_InteractTouch currentTouchingObject = null)
 {
     audioSource.Play();
     infectionStatus = currentTouchingObject.GetComponent <InfectionStatus> ();
     if (infectionStatus)
     {
         infectionCoroutine = StartCoroutine(InfectionTouchRoutine());
     }
     base.StartTouching(currentTouchingObject);
     Debug.Log("i'm being infected");
 }
Example #22
0
 public override void StopTouching(VRTK_InteractTouch previousTouchingObject = null)
 {
     base.StopTouching(previousTouchingObject);
     Debug.Log("i'm not touching anything infected");
     if (infectionCoroutine != null)
     {
         Debug.Log("Stop infection coroutine");
         StopCoroutine(infectionCoroutine);
         infectionStatus    = null;
         infectionCoroutine = null;
     }
 }
Example #23
0
        protected override void Awake()
        {
            originalControllerTongAttachPoint = controllerTongAttachPoint;
            controllerEvents  = (controllerEvents != null ? controllerEvents : GetComponentInParent <VRTK_ControllerEvents>());
            interactTongTouch = (interactTongTouch != null ? interactTongTouch : GetComponentInParent <VRTK_InteractTouch>());
            if (interactTongTouch == null)
            {
                VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_InteractGrab", "VRTK_InteractTouch", "interactTouch", "the same or parent"));
            }

            VRTK_SDKManager.AttemptAddBehaviourToToggleOnLoadedSetupChange(this);
        }
Example #24
0
        public override void OnEnter()
        {
            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            touch = go.GetComponent <VRTK_InteractTouch>();

            doTouch();
            if (!everyFrame.Value)
            {
                Finish();
            }
        }
Example #25
0
    private void Awake()
    {
        if (GetComponent <VRTK_InteractTouch>() == null)
        {
            Debug.LogError("VRTK_InteractUse is required to be attached to a SteamVR Controller that has the VRTK_InteractTouch script attached to it");
            return;
        }

        interactTouch     = GetComponent <VRTK_InteractTouch>();
        trackedController = GetComponent <SteamVR_TrackedObject>();
        controllerActions = GetComponent <VRTK_ControllerActions>();
    }
Example #26
0
    private void Awake()
    {
        if (GetComponent <VRTK_InteractTouch>() == null)
        {
            Debug.LogError("VRTK_InteractGrab is required to be attached to a Controller that has the VRTK_InteractTouch script attached to it");
            return;
        }

        interactTouch     = GetComponent <VRTK_InteractTouch>();
        controllerActions = GetComponent <VRTK_ControllerActions>();
        controllerEvents  = GetComponent <VRTK_ControllerEvents>();

        grabbedObjectList = new List <GameObject>();
    }
    //private bool m_IsClearSpawnObject;

    private void Start()
    {
        if (m_InteractTouch == null)
        {
            m_InteractTouch = GetComponent <VRTK_InteractTouch>();
        }

        if (m_InteractGrab == null)
        {
            m_InteractGrab = GetComponent <VRTK_InteractGrab>();
        }

        EventCenter.AddListener(EventDefine.SpawnModem, SpwanModem);
        EventCenter.AddListener(EventDefine.SpawnDrill, SpwanDrill);
        EventCenter.AddListener(EventDefine.SpawnCable, SpwanCable);
    }
Example #28
0
        public void Enable(IHandController ctl)
        {
            if (touch != null)
            {
                GameObject.Destroy(touch);
            }
            if (grab != null)
            {
                GameObject.Destroy(grab);
            }

            touch = ctl.gameObject.AddComponent <VRTK_InteractTouch>();
            grab  = ctl.gameObject.AddComponent <VRTK_InteractGrab>();

            grab.controllerEvents = ctl.Events;
            grab.interactTouch    = touch;
        }
Example #29
0
    public override void StartTouching(VRTK_InteractTouch currentTouchingObject = null)
    {
        base.StartTouching(currentTouchingObject);

        if (capacitorPlate == null)
        {
            return;
        }

        capacitorPlate.EnableResizeObjects(true);
        capacitorPlate.ToggleHighlight(true);

        // Ignore controller collisions with capacitor plate to not interrupt resizing
        foreach (Collider usingCollider in currentTouchingObject.GetComponentsInChildren <Collider>())
        {
            Physics.IgnoreCollision(capacitorPlate.GetComponent <Collider>(), usingCollider, true);
        }
    }
Example #30
0
    public override void StopTouching(VRTK_InteractTouch previousTouchingObject = null)
    {
        base.StopTouching(previousTouchingObject);

        if (capacitorPlate == null)
        {
            return;
        }

        capacitorPlate.ToggleHighlight(false);
        capacitorPlate.EnableResizeObjects(false);

        // Reset ignore controller collision with capacitor plate to enable plate touching
        foreach (Collider usingCollider in previousTouchingObject.GetComponentsInChildren <Collider>())
        {
            Physics.IgnoreCollision(capacitorPlate.GetComponent <Collider>(), usingCollider, false);
        }
    }