- Home /
Accurate ScreenPointToRay regardless of camera rotation
It might not be possible I want to have an accurate ScreenPointToRay regardless of camera rotation. As you can see in the first image, this is what a ScreenPointToRay looks like on an orthographic camera sized at 5.625 with a sprite PPU of 32 and a camera X rotation of 0. It is represented by the green line on the scene view (right side).
Now in my game the perspective is isometric somewhat so my camera's X rotation is 60. To compensate, all my sprites are blown up twice in the Y scale, so my sprites have a scale of (1,2,1). This is to keep pixel perfection of my bullseye sprite while the camera is rotated. Here's how ScreenPointToRay looks when the camera's X rotation is 60.
Take note of the mouse cursors based on the two images. You can see on the second image that the ray is a not as exact as the first image. I need my mouse pointer rays to be accurate as there will be bullseye mechanics and each shot needs to be accurate based on the mouse cursor. I know that the ray's origin is now higher up now that the camera is rotating 60 in the X direction, so the casted ray is hitting the collider earlier and from an angle compared to if the rotation is 0. But is there a way to get the ray accurate while the camera is rotated? Thanks!