0 votes

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")
in Engine by (34 points)

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

1 Answer

0 votes

You ray doesn't have length.
Try:

var to = camera.project_ray_normal(mousePos) * 1000
by (31 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.