private void DeactiveLastInteractible() { if (m_LastInteractible == null) return; m_LastInteractible.Out(); m_LastInteractible = null; }
/*[Command] public void Cmd_touchObject(string itmName) { //not that kind of touch, you pervs. //Debug.Log("Touched"); GameObject itemObj = NetworkServer.FindLocalObject(GameObject.Find(itmName).GetComponent<NetworkIdentity>().netId); itemObj.GetComponent<VRInteractiveItem>().hasBeenTouched = true; }*/ private void EyeRaycast() { // Show the debug ray if required if (m_ShowDebugRay) { Debug.DrawRay(m_Camera.position, m_Camera.forward * m_DebugRayLength, Color.blue, m_DebugRayDuration); } // Create a ray that points forwards from the camera. Ray ray = new Ray(m_Camera.position, m_Camera.forward); RaycastHit hit; // Do the raycast forweards to see if we hit an interactive item if (Physics.Raycast(ray, out hit, m_RayLength, ~m_ExclusionLayers)) { //set flashlight reference object transform //GameObject flashlightObj = transform.Find("Camera Player/pFlashLight").gameObject; //flashlightObj.transform.position = hit.point; VRInteractiveItem_Single interactible = hit.collider.GetComponent<VRInteractiveItem_Single>(); //attempt to get the VRInteractiveItem on the hit object m_CurrentInteractible = interactible; //If the object hit by the raycast has a VRInteractiveItem Script, tell that object to get the inventory script from the raycasting player if (interactible != null) { currentInteractibleName = interactible.gameObject.name; //For Ryan //This will most likely need a Cmd written for it. Let me test it first -R hit.transform.SendMessage("RetrieveInventoryScript", gameObject); //If there is a manipulate script attached to the object you're looking at, send it the player's inspect point transform if (hit.transform.gameObject.GetComponent<VRStandardAssets.Examples.spt_interactiveItemManipulate>() != null) hit.transform.SendMessage("RetrieveLookPoint", gameObject); //also ensure we flag that this has been interacted with. //If the player presses A while looking at an interactible, set that interactible to touched //if ( Input.GetButtonDown( "Fire1" ) ) Cmd_touchObject(interactible.gameObject.name); } // If we hit an interactive item and it's not the same as the last interactive item, then call Over if (interactible && interactible != m_LastInteractible) interactible.Over(); // Deactive the last interactive item if (interactible != m_LastInteractible) DeactiveLastInteractible(); m_LastInteractible = interactible; // Something was hit, set at the hit position. if (m_Reticle) { m_Reticle.SetPosition(hit); racyCastTouch = true; } if (OnRaycasthit != null) { OnRaycasthit(hit); } } else { // Nothing was hit, deactive the last interactive item. DeactiveLastInteractible(); m_CurrentInteractible = null; racyCastTouch = false; // Position the reticle at default distance. if (m_Reticle) m_Reticle.SetPosition(); } }