private void Awake() { rig = GetComponent <XRRig>(); health = GetComponent <Health>(); health.dieEvent.AddListener(Die); health.damageEvent.AddListener(Damaged); }
void Start() { rig = GetComponent <XRRig>(); //finds every object in the radius of it's transform to determine planet we are standing on Collider[] hitColliders = Physics.OverlapSphere(this.transform.position, 6, groundedMask); float tempDistance = 200; //could mess with this if working with different size planets foreach (Collider col in hitColliders) { if (col.gameObject.tag.Equals("Element") && Vector3.Distance(this.transform.position, col.transform.position) < tempDistance) { tempDistance = Vector3.Distance(this.transform.position, col.transform.position); GravMgr.currentPlanet = col.gameObject.GetComponentInChildren <Gravity2>().gameObject; /*if (GravMgr.currentPlanet.tag == "CubeBridge") //prevents you from flying off the cube at initialization * { * GravMgr.currentPlanet.GetComponent<Gravity2>().isBridgeTransitioning = true; * StartCoroutine(GravMgr.currentPlanet.GetComponent<Glow>().BridgeTransition(1)); * }*/ print(GravMgr.currentPlanet.name + "curPl"); break; } } if (GravMgr.currentPlanet.GetComponent <Gravity2>().shape == Gravity2.planetShape.cubeBridge) { GravMgr.currentPlanet.GetComponent <Gravity2>().gravCube.GetComponent <GravCube>().enabled = true; } print(GravMgr.currentPlanet.name + "is current planet"); }
// Start is called before the first frame update void Start() { // set the character equal to the component it has character = GetComponent <CharacterController>(); //set the rig equal to the Rig component rig = GetComponent <XRRig>(); }
// Start is called before the first frame update void Start() { character = GetComponent <CharacterController>(); rig = GetComponent <XRRig>(); //finds every object in the radius of it's transform to determine planet we are standing on Collider[] hitColliders = Physics.OverlapSphere(this.transform.position, 6, groundedMask); float tempDistance = 200; //could mess with this if working with different size planets foreach (Collider col in hitColliders) { if (Vector3.Distance(this.transform.position, col.transform.position) < tempDistance) { tempDistance = Vector3.Distance(this.transform.position, col.transform.position); GravMgr.currentPlanet = col.gameObject.GetComponentInChildren <Gravity2>().gameObject; if (GravMgr.currentPlanet.tag == "CubeBridge") //prevents you from flying off the cube at initialization { GravMgr.currentPlanet.GetComponent <Gravity2>().isBridgeTransitioning = true; StartCoroutine(GravMgr.currentPlanet.GetComponent <Glow>().BridgeTransition(1)); } print(GravMgr.currentPlanet.name + "curPl"); break; } } }
internal static XRRig CreateXRRig() { GameObject xrRigGO = new GameObject(); xrRigGO.name = "XR Rig"; XRRig xrRig = xrRigGO.AddComponent <XRRig>(); // add camera offset GameObject cameraOffsetGO = new GameObject(); cameraOffsetGO.name = "CameraOffset"; cameraOffsetGO.transform.SetParent(xrRig.transform, false); xrRig.cameraFloorOffsetObject = cameraOffsetGO; xrRig.transform.position = Vector3.zero; xrRig.transform.rotation = Quaternion.identity; // camera and track pose driver GameObject cameraGO = new GameObject(); cameraGO.name = "Camera"; var camera = cameraGO.AddComponent <Camera>(); cameraGO.transform.SetParent(cameraOffsetGO.transform, false); xrRig.cameraGameObject = cameraGO; XR.XRDevice.DisableAutoXRCameraTracking(camera, true); return(xrRig); }
// Start is called before the first frame update void Start() { //chercher le composant de characterController character = GetComponent <CharacterController>(); //chercher le rig rig = GetComponent <XRRig>(); }
bool IsOnSameRigAsOtherEquippables(XREquippableReceiver targetReceiver) { // Try to find an XRRig in other equippables. XRRig othersRig = null; foreach (var otherEquippable in otherEquippables) { try { othersRig = otherEquippable.CurrentReceiver.GetComponentInParent <XRRig>(); break; } catch { } } // If we found a rig, check if it is the same rig as the one we are targetting. if (othersRig) { return(othersRig == targetReceiver.GetComponentInParent <XRRig>()); } else { return(true); } }
// Start is called before the first frame update void Awake() { // Get components rig = GetComponent <XRRig>(); controller = transform.parent.GetComponent <CharacterController>(); playerScript = player.GetComponent <Player>(); }
// Start is called before the first frame update void Start() { gm = GameObject.Find("GameManager"); controlls = gm.GetComponent <VRMapping>(); character = GameObject.Find("Mech").GetComponent <CharacterController>(); rig = xrRig.GetComponent <XRRig>(); }
void SetFocusCameraPosition(XRRig xrRig, Vector3 focusPoint) { var cameraPlane = new Plane(xrRig.transform.forward, xrRig.transform.position); var targetCameraPos = cameraPlane.ClosestPointOnPlane(focusPoint); xrRig.MoveCameraToWorldLocation(targetCameraPos); }
void Start() { if (m_XrRig == null) { m_XrRig = FindObjectOfType <XRRig>(); } m_XrRayInteractor = GetComponent <XRRayInteractor>(); m_XrInteractorLineVisual = GetComponent <XRInteractorLineVisual>(); m_LinePoints = new Vector3[k_MaxLinePoints]; m_TeleportationTarget.gameObject.SetActive(false); m_MainCamera = Camera.main.transform; m_DisposeOnDestroy.Add(m_RootSelector = UISelectorFactory.createSelector <Transform>(PipelineContext.current, nameof(IPipelineDataProvider.rootNode))); m_DisposeOnDestroy.Add(m_CamInfoSelector = UISelectorFactory.createSelector <CameraTransformInfo>(ProjectContext.current, nameof(ITeleportDataProvider.cameraTransformInfo))); m_DisposeOnDestroy.Add(m_TeleportPickerSelector = UISelectorFactory.createSelector <IPicker>(ProjectContext.current, nameof(ITeleportDataProvider.teleportPicker), async => { SetInitialTeleportDistance(); })); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <SetActiveToolAction.ToolType>(ToolStateContext.current, nameof(IToolStateDataProvider.activeTool), type => { m_CanTeleport = type != SetActiveToolAction.ToolType.SelectTool; })); m_TeleportAction = m_InputActionAsset["VR/Teleport"]; m_InputActionAsset["VR/Select"].performed += OnTeleport; }
public IEnumerator XRPlayerController_XRRig_Setup() { SceneManager.LoadScene(SCENE_TO_LOAD); yield return(new WaitForSeconds(SCENE_WAIT_TIME)); XRRig = GameObject.FindObjectOfType <XRRig>(); }
private void Awake() { player = GameObject.Find("XR Rig").transform; xr = GameObject.Find("XR Rig").GetComponent <XRRig>(); ph = GameObject.Find("XR Rig").GetComponent <PlayerHealth>(); //player = new Vector3(xr.rigInCameraSpacePos.x, xr.rigInCameraSpacePos.y, xr.rigInCameraSpacePos.z); //player = xr.rig.transform.position; agent = GetComponent <NavMeshAgent>(); }
// Start is called before the first frame update void Start() { photonView = GetComponent <PhotonView>(); XRRig rig = FindObjectOfType <XRRig>(); headRig = rig.transform.Find("Camera Offset/Main Camera"); leftHandRig = rig.transform.Find("Camera Offset/LeftHand Controller"); rightHandRig = rig.transform.Find("Camera Offset/RightHand Controller"); }
private void OnValidate() { if (!target) { // By default, look at the camera XRRig rig = FindObjectOfType <XRRig>(); target = rig.cameraGameObject.transform; } }
private void Start() { if (rig == null) { rig = FindObjectOfType <XRRig>(); } RegisterInputFields(); transform.localScale = Vector3.zero; }
private void Start() { character = GetComponent <CharacterController>(); rig = GetComponent <XRRig>(); rb = GetComponent <Rigidbody>(); art = GetComponent <Arts>(); leftHand = InputDevices.GetDeviceAtXRNode(leftSource); rightHand = InputDevices.GetDeviceAtXRNode(rightSource); }
// Start is called before the first frame update void Start() { XRRig rig = FindObjectOfType <XRRig>(); head.vrTarget = rig.transform.Find("Camera Offset/Main Camera"); leftHand.vrTarget = rig.transform.Find("Camera Offset/LeftHand Controller"); rightHand.vrTarget = rig.transform.Find("Camera Offset/RightHand Controller"); headBodyOffset = transform.position - headConstraint.position; StartDerived(); }
void Start() { InputDevices.GetDevicesAtXRNode(XRNode.RightEye, rightEyeDevice); sniperTransform = GetComponent <Transform>(); XRRig xrScript = xrRigGameObject.GetComponent <XRRig>(); headsetCamera = xrScript.cameraGameObject; scopeRenderingObject.SetActive(false); }
void Start() { rig = GetComponent <XRRig>(); footsteps = GetComponent <AudioSource>(); // Vector *pointing* towards origin. We remove the z axis because we // don't want to be pushed from the origin in the z axis, only in x/y. upAxis = (new Vector3(0, 0, 0) - rig.transform.position).normalized; upAxis = new Vector3(upAxis.x, upAxis.y, 0); rig.MatchRigUp(upAxis); }
void Awake() { UIStateManager.projectStateChanged += OnProjectStateDataChanged; if (m_XrRig == null) { m_XrRig = FindObjectOfType <XRRig>(); } m_RootCanvas = FindObjectOfType <UIStateManager>().GetComponent <Canvas>(); m_OriginalRootCanvasParent = m_RootCanvas.transform.parent; m_TrackedDeviceGraphicRaycasters = new List <TrackedDeviceGraphicRaycaster>(); m_VrAnchors = new List <VRAnchor>(); }
private void Awake() { if (instance != null) { Destroy(this.gameObject); } else { instance = this; DontDestroyOnLoad(this); } rig = GetComponent <XRRig>(); characterController = GetComponent <CharacterController>(); }
private void Start() { photonView = GetComponent <PhotonView>(); if (photonView.IsMine) { body.GetComponent <Renderer>().enabled = false; } XRRig rig = FindObjectOfType <XRRig>(); headRig = rig.transform.Find("Camera Offset/VR Camera"); leftHandRig = rig.transform.Find("Camera Offset/Left Hand"); rightHandRig = rig.transform.Find("Camera Offset/Right Hand"); }
// Start is called before the first frame update void Start() { photonView = GetComponent <PhotonView>(); XRRig rig = FindObjectOfType <XRRig>(); headRig = rig.transform.Find("Camera Offset/Main Camera"); leftHandRig = rig.transform.Find("Camera Offset/LeftHand Controller"); rightHandRig = rig.transform.Find("Camera Offset/RightHand Controller"); if (photonView.IsMine) { foreach (var item in GetComponentsInChildren <Renderer>()) { item.enabled = false; } } }
void Awake() { m_DisposeOnDestroy.Add(m_CamInfoGetter = UISelectorFactory.createSelector <CameraTransformInfo>(ProjectContext.current, nameof(ITeleportDataProvider.cameraTransformInfo), OnCameraTransformInfoChanged)); m_DisposeOnDestroy.Add(UISelectorFactory.createSelector <Project>(ProjectManagementContext <Project> .current, nameof(IProjectDataProvider <Project> .activeProject), OnActiveProjectChanged)); if (m_XrRig == null) { m_XrRig = FindObjectOfType <XRRig>(); } m_RootCanvas = FindObjectOfType <UIStateManager>().GetComponent <Canvas>(); m_OriginalRootCanvasParent = m_RootCanvas.transform.parent; m_TrackedDeviceGraphicRaycasters = new List <TrackedDeviceGraphicRaycaster>(); m_VrAnchors = new List <VRAnchor>(); m_Anchors = new List <VRAnchor.DeviceAlignmentAnchor>(); }
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { IEnumerator WaitAFrame() { yield return null; m_XRRig = Camera.main.GetComponentInParent<XRRig>(); if (m_XRRig != null) { m_VRCameraOffset.y = m_XRRig.cameraYOffset; } else if (m_VREnableSelector.GetValue()) { Debug.LogError("XRRig not found."); } } StartCoroutine(WaitAFrame()); }
/// <summary> /// Sets a new position and rotation for the XR Rig. /// </summary> /// <param name="destinationPosition">Target position.</param> /// <param name="destinationRotation">Target rotation.</param> public void SetRigPositionAndRotation(Vector3 destinationPosition, Quaternion destinationRotation) { if (CanBeginLocomotion() == false) { return; } XRRig xrRig = system.xrRig; if (xrRig != null) { Vector3 heightAdjustment = xrRig.rig.transform.up * xrRig.cameraInRigSpaceHeight; Vector3 cameraDestination = destinationPosition + heightAdjustment; xrRig.MatchRigUpCameraForward(destinationRotation * Vector3.up, destinationRotation * Vector3.forward); xrRig.MoveCameraToWorldLocation(cameraDestination); } }
// Start is called before the first frame update void Awake() { _rightray = rightControllerObj.GetComponent <XRInteractorLineVisual>(); _rightController = rightControllerObj.GetComponent <XRController>(); _rightLine = rightControllerObj.GetComponent <LineRenderer>(); _leftray = leftControllerObj.GetComponent <XRInteractorLineVisual>(); _leftController = leftControllerObj.GetComponent <XRController>(); _leftLine = leftControllerObj.GetComponent <LineRenderer>(); originalLineWidth = _rightLine.startWidth; XRRig_Script = player.GetComponent <XRRig>(); lineLength = _rightray.lineLength; currentReticleScale = reticlePrefab.transform.localScale = new Vector3(1, .05f, 1); _rightray.reticle = _leftray.reticle = reticlePrefab; }
void Start() { List <InputDevice> devices = new List <InputDevice>(); InputDevices.GetDevicesWithCharacteristics(characteristicsLeft, devices); if (devices.Count > 0) { lHandControllerDevice = devices[0]; } InputDevices.GetDevicesWithCharacteristics(characteristicsRight, devices); if (devices.Count > 0) { rHandControllerDevice = devices[0]; } myRig = GetComponent <XRRig>(); FPC = GetComponent <CharacterController>(); }
void Start() { pView = GetComponent <PhotonView>(); XRRig playerRig = FindObjectOfType <XRRig>(); VRHelmet = playerRig.transform.Find("Camera Offset/Main Camera"); lHandCtrl = playerRig.transform.Find("Camera Offset/LeftHand Controller"); rHandCtrl = playerRig.transform.Find("Camera Offset/RightHand Controller"); if (pView.IsMine) { head.gameObject.SetActive(false); body.gameObject.SetActive(false); lHand.gameObject.SetActive(false); rHand.gameObject.SetActive(false); } body.GetComponent <Renderer>().material.color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f)); }