I’m trying to use a ray cast on a mesh that is parented to the camera. Essentially I want the ray cast to come out of the camera and point in the direction of the camera. I’ve tried this a few different ways but keep running into the same issue. I want the ray to have an offset along the Y-axis. If I add in say “1” for the Y-axis value the ray no longer shoots straight forward but instead shoots down at an angle. Here is the playground:
Here is another try using a mesh as the origin point for the ray and using the camera as a parent:
I reset the position/rotation to match the camera but if I adjust the Y-axis position it again points the ray downward. I’m sure there is something here I’m missing in regards to rotation/positioning but I can’t figure it out.
The goal is to have a ray cast that shoots forward from the camera but offset along the Y-axis. I’m using this for a mobile game and displaying the crosshair a bit higher than center feels best for this game.
Because the ray is using (0,0,1) in local space of the mesh but it’s moved higher, the ray appears to go toward the horizon the longer it gets.
It’s not going downward. it’s appears to go downward because it gets further away.
Like on this image:
The road does not go up. but the difference between the eye and the road, projected on screen tends to 0 because it gets further away.
You need to change the mesh orientation so it gets more oriented on top/bottom of screen than in the middle.
Like this:
I suggest you to do a sketch on paper of the camera side projection to make it more clear
So if I understand correctly you’re essentially doing the equivalent of adjusting the sights of a rifle when shooting at different distances, is that correct? Thanks for the info! Marking solution.
not different distance but different height.
imagine hoding a rifle in your hand and you want to shoot a target 10meters ahead.
depending on the height you are holding the rifle, you have to adjust its orientation.
it’s a bit like a lookat.