Physics.Raycast doesn't respect Camera.rect

I’m doing raycast from the mousepointer using Physics.Raycast, no problem here. The odd thing is the raycasting doesn’t seem to respect the Camera Normalized View Port Rect. For example moving the mouse beyond the (clipped) camera.rect still returns raycasting hits. Is this expected behaviour?

When you mention from the mousepointer, I imagine you’re using screentoworldpoint to set the ray origin? If that’s the case then yes, it is expected behavior. Screen != camera bounds.

You would need to clip the mouse position input to whatever arbitrary rect yourself before casting the ray. You can use Camera.pixelRect to help you in that regard.

Ahh yes! Thanks for the info.