New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Camera.project_ray_origin always returns the origin of the camera when in perspective projection. #41872
Comments
To do a raycast you need 2 points, the point to start at, and the point to end at:
You can then use
I recommend you read over the Raycast Tutorial again. It explains this, as well as what info is contained in the result of |
Cheers, I figured this out soon after I posted this but couldn't figure out how to close the issue. Embarrassing. But now I'm wondering how I couldn't find the button- it's right there! |
" |
I know I'm "to late to the party" "project_ray_origin" exist because orthogonal camera origin is variable unlike perspective camera which is constant |
Godot version:
3.2.2
OS/device including version:
Windows 10
Issue description:
No matter what Vector2 is given to Camera.project_ray_origin, it just returns the camera's origin if the camera is in perspective projection. I see in the source that it does that on purpose, and always has.
I want to cast a ray from the mouse into the world from the camera in the direction the camera is facing. Using the code from the page on RayCasting results in an inaccurate ray origin because it's the same value regardless of where the mouse is in the viewport.
For example, I add two points to an ImmediateGeometry: Vector3(0,0,0) and
project_ray_origin(get_viewport().get_mouse_position())
. As you can see below, the ray origin is somewhere to the right, and doesn't depend on the mouse's position at all:If this is by design, then there's a documentation issue (it should note somewhere that it doesn't work for projection cameras), but then the question remains: how does one cast a ray from the mouse into world using a perspective camera?
Steps to reproduce:
project_ray_origin(get_viewport().get_mouse_position())
will not depend on the mouse position.Minimal reproduction project:
Demo.zip
The text was updated successfully, but these errors were encountered: