bella-1995 Posted March 19, 2021 Share Posted March 19, 2021 how to block raycast on ui or calliders of scene objects? The ray passes through, although the sphere shows the correct location (the ray sphere does not pass right through, but the ray itself apparently passes) and this triggers object scripts. Example3.zip Link to comment Share on other sites More sharing options...
VIVE_chengnay Posted March 19, 2021 Share Posted March 19, 2021 @bella-1995 You want to block the raycast and only hit the cube instead of the button behind the cube? Link to comment Share on other sites More sharing options...
bella-1995 Posted March 19, 2021 Author Share Posted March 19, 2021 (edited) Hello dear @chengnay. Yes, and when i press button i need only press button without trigger object behind. Edited March 19, 2021 by bella-1995 Link to comment Share on other sites More sharing options...
bella-1995 Posted March 19, 2021 Author Share Posted March 19, 2021 (edited) Now when I interact with the ui I accidentally click on the object behind the ui, I have a script added to the object so that when I select it with a raycast I can paint it. So when I click on the ui I select the ui and the object behind and both scripts are triggered.. Edited March 19, 2021 by bella-1995 Link to comment Share on other sites More sharing options...
VIVE_chengnay Posted March 19, 2021 Share Posted March 19, 2021 @bella-1995 Could you share your sample project or scripts for further investigation? Thanks! Link to comment Share on other sites More sharing options...
bella-1995 Posted March 22, 2021 Author Share Posted March 22, 2021 @chengnay I use Vive Input Utility example scen (ugui scen) this scen have all scripts what i use. I just add Debug.Log(raycastResult). And debug log shows me that raycast hitting all object in scen(You can see the result in example.zip which I added at the top). Both cubes have a box collider. Canvas have a canvas target. Nothing has been added to the scene except a couple of cubes and a debug log. if you really need the sources, I'll try to get them. Link to comment Share on other sites More sharing options...
VIVE_chengnay Posted March 22, 2021 Share Posted March 22, 2021 @bella-1995 Like you said, the raycastResult will list all objects that it hits. VIU will return the first one(nearest to you) when your raycast hits. We test on UGUI scene with a cube in front of the button, but we didn't see the button was pressed when I pull the trigger button. From the gif image you attached, the button didn't even being hovered when you hit it through the cube. Could you try again or provide the source for further investigation? thanks! Link to comment Share on other sites More sharing options...
lawwong Posted March 22, 2021 Share Posted March 22, 2021 Hi @bella-1995, I'm guessing you get "raycastResults" from ViveRaycaster.SortedRaycastResults ? That means this property stores all raycast results and sorted by hit distance, hence index 0 result is the nearest. (Or just use ViveRaycaster.FirstRaycastResult() function) Default UGUI event, reticle and guideline all interact with only the first raycast result, you can do the same. Alternatively you can also implement your interaction logic within the event handlers. FYR., more details from Unity docs: https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/SupportedEvents.html Link to comment Share on other sites More sharing options...
bella-1995 Posted March 22, 2021 Author Share Posted March 22, 2021 sorry, but maybe here i have a problem? (56-118) it's my custom code. 60 - 97 i check to press trigger on controller (if pressed i add a gameobject to gameobject list where i save all gameobject which i select from raycast). If this code without problem i will try to get clear project only with problem.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now