void TriggerPressedHandler(object sender, ControllerInteractionEventArgs e) { Ray ray = new Ray(transform.position, transform.forward); Ray viveRay = cam.ScreenPointToRay(UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftHand)); Debug.DrawRay(ray.origin, ray.direction, Color.blue, 3.0f); RaycastHit hit; if (Physics.Raycast(ray, out hit, distance)) { GameObject peice = hit.collider.gameObject; move mo = peice.GetComponent <move>(); mo.cmove(); } }
void Ray() { Ray ray = new Ray(transform.position, transform.forward); Debug.DrawRay(ray.origin, ray.direction, Color.blue, 10.0f); RaycastHit hit; if (Physics.Raycast(ray, out hit, 10.0f)) { GameObject peice = hit.collider.gameObject; string objectName = hit.collider.gameObject.name; Debug.Log(objectName); move mo = peice.GetComponent <move> (); mo.cmove(); } }
void Update() { if (Input.GetMouseButtonDown(0)) { Ray ray = subcam.ScreenPointToRay(Input.mousePosition); RaycastHit hit = new RaycastHit(); if (Physics.Raycast(ray, out hit, distance)) { GameObject peice = hit.collider.gameObject; // string objectName = hit.collider.gameObject.name; //Debug.Log(objectName); move mo = peice.GetComponent <move>(); mo.cmove(); } } }
void Update() { pointer.SetPosition(0, this.transform.position); RaycastHit hit; if (Physics.Raycast(this.transform.position, this.transform.forward * 10f, out hit, 100)) { pointer.SetPosition(1, hit.point); EnablePointer(); GameObject peice = hit.collider.gameObject; move mo = peice.GetComponent <move>(); mo.cmove(); } else { DisEnablePointer(); } }