Raycast from mouse

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Qushy

Hello I’m trying to raycast from the position of the mouse to something in the game world but it’s not working. My code:

ray.set_enabled(true)
var camera = get_node("Target/MainCamera")
var from = camera.project_ray_origin(mousePos)
var to = camera.project_ray_normal(mousePos)


 ray.cast_to = to
 ray.translation = from
	
 if ray.is_colliding() :
 print("found")

I’m not entirely sure but don’t you set the day length too short this way?

KijeviGombooc | 2019-07-23 10:38

:bust_in_silhouette: Reply From: Vododovoodvod

You ray doesn’t have length.
Try:

var to = camera.project_ray_normal(mousePos) * 1000