Rays, Points and Ports

I’d like to be able to get the position in worldspace that corresponds to the pixel rendering at a specific location in the viewport.

I’ve seen how I can use ScreenPointToRay to get this information on the location I have clicked on in the viewport. But what I want is the same information returned for a specific position in the viewport.

I want this so that I can fire a projectile along a ray cast from the viewport camera to the location under a reticle that oves around inside the viewport.

Any suggestions?

ViewportToWorldPoint?

I thought that might be the rascal I was looking for, but I can’t figure out how to write any code for it.

Boy, I can’t wait until the Unity online reference has a code example for each class and method.

Nevermind, I figured it out.

Turns out I needed to use ‘‘WorldToScreenPoint’’.