public static void Destroy(GameObject gameObject, System.Action <GameObject> DestroyHandler = null) { XRGrabInteractable grabComponent = gameObject.GetComponent <XRGrabInteractable>(); // If the object is not a grabbable or if it is not selected, destroy now. if (!grabComponent || !grabComponent.isSelected) { if (DestroyHandler == null) { Object.Destroy(gameObject); } else { DestroyHandler(gameObject); } return; } // Destroy when we get dropped, and force drop. grabComponent.onSelectExit.AddListener(delegate { if (DestroyHandler == null) { Object.Destroy(gameObject); } else { DestroyHandler(gameObject); } }); grabComponent.selectingInteractor.DropObjectNow(); }
private void Awake() { var blood = GetComponent <BloodParticleSystem>(); if (blood != null) { bloodParticleSystem = blood; } var copyMotion = GetComponent <CopyMotion>(); if (copyMotion != null) { isCopyMotionTarget = true; AddScriptToChild(transform); } else { AddScript(transform); AddScriptToChild(transform); } var interactive = GetComponent <XRGrabInteractable>(); if (interactive != null) { _interactable = interactive; isInteractable = true; } }
// Start is called before the first frame update void Awake() { _XRGrabInteractable_script = GetComponent <XRGrabInteractable>(); _XRGrabInteractable_script.onActivate.AddListener(SpawnBall); _XRGrabInteractable_script.onDeactivate.AddListener(RestartSpawner); }
void Start() { if (grabInteractable == null) { grabInteractable = GetComponent <XRGrabInteractable>(); } }
/// <summary> /// Attach the XRGrabInteractable in the center (+offset) of the socket. Also makes the Rigidbody kinematic /// </summary> /// <param name="objectToAttach">The XRGrabInteractable to attach</param> private void Attach(XRGrabInteractable objectToAttach) { Debug.Log($"Attach {objectToAttach}"); socketedInteractable = objectToAttach; baseScale = socketedInteractable.transform.localScale; // since XRGrabInteractable modifies the rigidbodies after grab event we must modify the rigidbody after it does socketedInteractable.selectExited.AddListener(_ => { Debug.Log("Select exit Attach"); var rb = socketedInteractable.GetComponent <Rigidbody>(); rb.useGravity = false; rb.isKinematic = true; socketedInteractable.transform.parent = transform; socketedInteractable.transform.localRotation = Quaternion.identity; // set the socketInteractable rotation the same as the parent socket socketedInteractable.selectExited.RemoveAllListeners(); }); // force drop the holdedObject and don't allow regrab it with the same input socketedInteractable.selectingInteractor.allowSelect = false; StartCoroutine(AllowSelect(socketedInteractable.selectingInteractor)); socketedInteractable.retainTransformParent = false; socketedInteractable.transform.position = transform.position + offsetY * transform.up; socketedInteractable.selectEntered.AddListener(_ => Release()); // once the object is in the inventory the grab event will release it parentInventory.AddObject(socketedInteractable.gameObject); }
void Awake() { Interactable = GetComponent <XRGrabInteractable>(); Effect.Play(); GameObject[] FirePoints = GameObject.FindGameObjectsWithTag("AirStrike"); FirePoint = FirePoints[0].transform; }
void Awake() { Interactable = GetComponent <XRGrabInteractable>(); PlayerShip = GameObject.Find("Ship"); PlayerGun = PlayerShip.GetComponent <Shoot>(); Effect.Play(); }
protected override void Awake() { base.Awake(); collider = GetComponent <Collider>(); xrGrabInteractable = GetComponent <XRGrabInteractable>(); }
// Start is called before the first frame update void Start() { grabInteractable = GetComponent <XRGrabInteractable>(); grabInteractable.onActivate.AddListener(MakeBig); grabInteractable.onDeactivate.AddListener(MakeBig); }
private void Awake() { meshrenderer = GetComponent <MeshRenderer>(); grabInteractable = GetComponent <XRGrabInteractable>(); grabInteractable.onActivate.AddListener(Eat); }
void Start() { m_InteractableBase = GetComponent <XRGrabInteractable>(); m_InteractableBase.onSelectExit.AddListener(DroppedGun); m_InteractableBase.onActivate.AddListener(TriggerPulled); m_InteractableBase.onDeactivate.AddListener(TriggerReleased); }
void Awake() { Interactable = GetComponent <XRGrabInteractable>(); PlayerShip = GameObject.Find("Ship"); PlayerHealth = PlayerShip.GetComponent <PlayerLifes>(); Effect.Play(); }
void Start() { hologram.SetActive(false); m_InteractableBase = GetComponent <XRGrabInteractable>(); m_InteractableBase.selectExited.AddListener(HologramDropped); m_InteractableBase.activated.AddListener(TriggerPulled); m_InteractableBase.deactivated.AddListener(TriggerReleased); }
private void Awake() { meshRenderer = GetComponent <MeshRenderer>(); grabInteractable = GetComponent <XRGrabInteractable>(); grabInteractable.onActivate.AddListener(SetPink); grabInteractable.onDeactivate.AddListener(SetGrey); }
private void Awake() { rendy = GetComponent <MeshRenderer>(); grabInteractable = GetComponent <XRGrabInteractable>(); grabInteractable.onHoverEnter.AddListener(SetMaterialA); grabInteractable.onHoverExit.AddListener(SetMaterialB); }
protected void Start() { m_InteractableBase = GetComponent <XRGrabInteractable>(); m_Animator = GetComponent <Animator>(); m_InteractableBase.selectExited.AddListener(DroppedGun); m_InteractableBase.activated.AddListener(TriggerPulled); m_InteractableBase.deactivated.AddListener(TriggerReleased); }
private void Awake() { // get the interactable component XRGrabInteractable grabInteractable = GetComponent <XRGrabInteractable>(); // create a listener to detect when the trigger is called, if true call the flareTrigger method grabInteractable.onActivate.AddListener(TriggerRope); }
protected virtual void Awake() { _interactableWeapon = GetComponent <XRGrabInteractable>(); _rb = GetComponent <Rigidbody>(); SetupInteractableEvents(); customAttachPointTransform = GameObject.Find("RightHand Interactor").transform.GetChild(1); //definedRecoilVector = customAttachPointTransform.forward; }
void Awake() { grabInteractable = GetComponent <XRGrabInteractable>(); if (lifetime > 0f) { Invoke(nameof(Break), lifetime); } }
// Start is called before the first frame update void Start() { // HitSound = GetComponent<AudioSource>(); if (grabInteractable == null) { grabInteractable = GetComponent <XRGrabInteractable>(); } // StartCoroutine(HitBoxTimeout()); }
// Start is called before the first frame update void Start() { scaledWalkingProvider = XRRig.GetComponent <ScaledWalkingProvider>(); walkingProvider = XRRig.GetComponent <WalkingProvider>(); grabInteractable = GetComponent <XRGrabInteractable>(); grabInteractable.onSelectEnter.AddListener(EnableScaledWalking); grabInteractable.onSelectExit.AddListener(DisableScaledWalking); meshCollider = GetComponent <MeshCollider>(); }
void Awake() { grabInteractable = GetComponent <XRGrabInteractable>(); rb = GetComponent <Rigidbody>(); grabInteractable.onSelectEnter.AddListener(StopAttach); grabInteractable.onSelectExit.AddListener(AttachToBoard); }
private void Awake() { mat_Original = GetComponent <Material>(); meshRenderer = GetComponent <MeshRenderer>(); grabbableObj = GetComponent <XRGrabInteractable>(); grabbableObj.onActivate.AddListener(SetHighlight); grabbableObj.onDeactivate.AddListener(SetOriginal); grabbableObj.onHoverEnter.AddListener(SetHover); }
protected void OnEnable() { m_GrabInteractable = GetComponent <XRGrabInteractable>(); m_MeshRenderer = GetComponent <MeshRenderer>(); m_GrabInteractable.onFirstHoverEntered.AddListener(OnFirstHoverEntered); m_GrabInteractable.onLastHoverExited.AddListener(OnLastHoverExited); m_GrabInteractable.onSelectEntered.AddListener(OnSelectEntered); m_GrabInteractable.onSelectExited.AddListener(OnSelectExited); }
protected virtual void Awake() { if (gameObject.layer != 13) { _interactableWeapon = GetComponent <XRGrabInteractable>(); } _rigidBody = GetComponent <Rigidbody>(); SetupInteractableWeaponEvents(); }
void OnEnable() { m_GrabInteractable = GetComponent <XRGrabInteractable>(); m_MeshRenderer = GetComponent <MeshRenderer>(); m_GrabInteractable.onFirstHoverEnter.AddListener(OnHoverEnter); m_GrabInteractable.onLastHoverExit.AddListener(OnHoverExit); m_GrabInteractable.onSelectEnter.AddListener(OnGrabbed); m_GrabInteractable.onSelectExit.AddListener(OnReleased); }
internal static XRGrabInteractable CreateGrabInteractable() { GameObject interactableGO = new GameObject("Grab Interactable"); CreateGOSphereCollider(interactableGO, false); XRGrabInteractable interactable = interactableGO.AddComponent<XRGrabInteractable>(); var rigidBody = interactableGO.GetComponent<Rigidbody>(); rigidBody.useGravity = false; rigidBody.isKinematic = true; return interactable; }
private void Awake() { meshRenderer = GetComponent <MeshRenderer>(); mat_Original = meshRenderer.material; grabObject = GetComponent <XRGrabInteractable>(); grabObject.onHoverEnter.AddListener(SetHoverMaterial); grabObject.onHoverExit.AddListener(SetOriginalMaterial); grabObject.onHoverEnter.AddListener(SetHighlightMaterial); }
void Awake() { grabInteractable = GetComponent <XRGrabInteractable>(); audioSource = GetComponent <AudioSource>(); reloadingImage.SetActive(false); grabInteractable.onActivate.AddListener(FireBullet); grabInteractable.onDeactivate.RemoveListener(FireBullet); }
static void DisableDelayProperties(XRGrabInteractable grabInteractable) { grabInteractable.velocityDamping = 1f; grabInteractable.velocityScale = 1f; grabInteractable.angularVelocityDamping = 1f; grabInteractable.angularVelocityScale = 1f; grabInteractable.attachEaseInTime = 0f; var rigidbody = grabInteractable.GetComponent <Rigidbody>(); rigidbody.maxAngularVelocity = float.PositiveInfinity; }