1128 Posted June 26, 2019 Share Posted June 26, 2019 how can i instantiate gameobject at raycast hit point from the controller here is my code but unable to get result public GameObject controller_right; // controller loader private void Update(){ RaycastHit hit;Vector3 c_pos = controller_right.transform.position;Vector3 direction = controller_right.transform.forward;Debug.DrawRay(c_pos, direction, Color.red);if(Physics.Raycast(c_pos,direction, out hit)){display.text = hit.transform.gameObject.name.ToString();if(hit.point != null){if(WaveVR_Controller.Input(WVR_DeviceType.WVR_DeviceType_Controller_Right).GetPressDown(WVR_InputId.WVR_InputId_Alias1_Trigger)){GameObject obj = Instantiate(sphere);obj.transform.position = hit.point;}}} ( - Tag added by moderator) Link to comment Share on other sites More sharing options...
Tony PH Lin Posted June 27, 2019 Share Posted June 27, 2019 Hi , In current SDK, it's not supported to get position of hit point, and we have plan into next release. Here is the short-term solution (with sample code) for your reference. 1. Please download and unzip the file (WaveVR_RaycastResult.zip) and put on the directory: Assets/WaveVR/Scripts/EventSystem/ Then modify WaveVR_ControllerInputModule.cs by adding the code ( see red color session) 2. Modify your code as below: WaveVR_RaycastResult result = WaveVR_RaycastResultProvider.Instance.GetRaycastResult ( WaveVR_Controller.GetEDeviceByWVRType (WVR_DeviceType.WVR_DeviceType_Controller_Right) // right controller ); Debug.Log ("World position of hit: " + result.worldPosition); Debug.Log ("Gameobject of hit: " + result.gameObject); Let me know if it's helpful for you. Thanks. Link to comment Share on other sites More sharing options...
1128 Posted July 1, 2019 Author Share Posted July 1, 2019 thank you , i will try your suggest some other time but for now i made "controller prefab " gameobject from controllerloader script as public and casting ray from that gameobjects position and rotation. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.