Casting rays from object with camera perspektive angle (fov)

Hello guys!

Currently I’m working on a project, where I get positional data from a camera sensor, which is placed on a ceiling. It’s able to detect, if something touches the wall and gives that information back to me.

In the end, a projector on the wall should show the game view, and make everything interactable, just like a giant touchscreen. I managed to extract the positional data and convert it to Unity so it currently looks like that:


(The red ray drawn is my hand touching the wall)

So far so good. The problem I encounter is, that by shooting the ray straight forward, the perspective view of the camera doesn’t get covered at all. Currently the sensor acts like an orthogonal camera view.

The question I have is, how it would be possible to shoot out the rays at an angle, to cover the whole fov of the camera, like this for instance:

Thanks for your help in advance!

Where are you getting the ray from? If you get it from the Camera API, it will give you an appropriate ray. Check in the Camera docs for calls containing the word “ray”

1 Like

Hey, I already got it to work. The way I fixed this error, was by offsetting the ray origin, to the camera position, and shooting the ray in the direction of the point where the sensor recognizes a touch!

Now everything works just as intended :slight_smile:

1 Like