Selector Raycast Inaccurate [SOLVED]
Selector Raycast Inaccurate [SOLVED]
Hello,
I have an issue where the RayCast is completely inaccurate making interacting with Usables extremely difficult. I am using the CInemachineSelector.cs posted on the forum, but the issue also happens with the regular Selector.
I have enabled a Debug.DrawLine to show the issue.
As you can see in the scene view the red debug cast is intersecting with the sphere this is causing the selector UI to display in the game view, even though I am not looking directly at the sphere.
Any ideas what is happening?
I have an issue where the RayCast is completely inaccurate making interacting with Usables extremely difficult. I am using the CInemachineSelector.cs posted on the forum, but the issue also happens with the regular Selector.
I have enabled a Debug.DrawLine to show the issue.
As you can see in the scene view the red debug cast is intersecting with the sphere this is causing the selector UI to display in the game view, even though I am not looking directly at the sphere.
Any ideas what is happening?
- Attachments
-
- issue.png (979.6 KiB) Viewed 389 times
Last edited by ojh.games on Fri Jun 23, 2023 8:39 am, edited 1 time in total.
Re: Selector Raycast Inaccurate
Hi,
Let's look at the regular Selector. What are the settings on your Selector component?
Let's look at the regular Selector. What are the settings on your Selector component?
Re: Selector Raycast Inaccurate
Hey, thanks for the reply!
I'm having the same result with both the regular selector and Cinemachine one. Here are the settings:
I'm having the same result with both the regular selector and Cinemachine one. Here are the settings:
- Attachments
-
- CinemachineSelector.png (37.94 KiB) Viewed 382 times
-
- Selector.png (43.75 KiB) Viewed 382 times
Re: Selector Raycast Inaccurate
Would it be possible for you to send reproduction steps or a reproduction project to tony (at) pixelcrushers.com?
I'm not sure how to reproduce the issue. I suspect it might have something to do with what the Selector thinks are the camera or screen bounds.
Have you also checked How To: Fix Selector and Proximity Selector Issues?
I'm not sure how to reproduce the issue. I suspect it might have something to do with what the Selector thinks are the camera or screen bounds.
Have you also checked How To: Fix Selector and Proximity Selector Issues?
Re: Selector Raycast Inaccurate
I've just realised, my game is set to 4:3 aspect ratio, I tried setting it to 16:9 and that sorted the issue out. So, it seems to be an aspect ration problem.
Re: Selector Raycast Inaccurate
I'll check that out now.
Re: Selector Raycast Inaccurate
I just tested multiple aspect ratios, including 4:3, and they seem to work correctly.
The raycast uses this ray to do a raycast:
screenCenter = Vector3(Screen.width / 2, Screen.height / 2)
Camera.main.ScreenPointToRay(screenCenter)
Would it be possible for you to send me a reproduction project?
The raycast uses this ray to do a raycast:
screenCenter = Vector3(Screen.width / 2, Screen.height / 2)
Camera.main.ScreenPointToRay(screenCenter)
Would it be possible for you to send me a reproduction project?
Re: Selector Raycast Inaccurate
Thanks, I have sent you an email with the project files.
Re: Selector Raycast Inaccurate
Hi,
Thanks for sending the repro project.
The issue is because your camera is rendering to a render texture. The render texture has a different resolution from the screen, but your Selector's Select At dropdown is set to Center Of Screen. You can resolve this by overriding GetSelectionPoint() in your CinemachineSelector script:
Thanks for sending the repro project.
The issue is because your camera is rendering to a render texture. The render texture has a different resolution from the screen, but your Selector's Select At dropdown is set to Center Of Screen. You can resolve this by overriding GetSelectionPoint() in your CinemachineSelector script:
Code: Select all
protected override Vector3 GetSelectionPoint()
{
return new Vector3(320, 240);
}
Re: Selector Raycast Inaccurate
You are absolutely right! I feel daft for missing that, thanks very much! That has saved me from a lot of frustration.