Godot: Add a way to directly perform a Raycast from a Camera

Created on 24 Jul 2018  路  2Comments  路  Source: godotengine/godot

Godot version: 3.0.5 +

https://godot.readthedocs.io/en/latest/classes/class_camera.html

The Camera node has some methods for assisting with projecting rays, but none of these methods actually perform full Raycasts. I think it would be useful to have a method which returns a RayCast object containing a RayCast from the mouse position on the screen into the world. That way, I could, for example, simply run get_collision_point() on that returned RayCast object to figure out the 3D point on a CollisionShape in the world that the camera is pointing at.

archived feature proposal core

Most helpful comment

Why not just:

  • Putting a RayCast node as child of the camera pointing forwards?
  • Or doing the raycast via code using space_state.intersect_ray, -transform.basis.z or projection with a few lines of script?

I don't think physical raycasting should be part of a Camera node when it can be so easily done with a simple setup.

All 2 comments

Why not just:

  • Putting a RayCast node as child of the camera pointing forwards?
  • Or doing the raycast via code using space_state.intersect_ray, -transform.basis.z or projection with a few lines of script?

I don't think physical raycasting should be part of a Camera node when it can be so easily done with a simple setup.

https://godotengine.org/qa/1996/ray-casting-from-the-camera-in-3d

also input_ray_pickable may also help if you're trying to pick objects from your camera and mouse.
http://docs.godotengine.org/en/3.0/classes/class_collisionobject.html#member-variables

Was this page helpful?
0 / 5 - 0 ratings

Related issues

n-pigeon picture n-pigeon  路  3Comments

mefihl picture mefihl  路  3Comments

ducdetronquito picture ducdetronquito  路  3Comments

timoschwarzer picture timoschwarzer  路  3Comments

testman42 picture testman42  路  3Comments