Hi, i'm having a hard time trying to raycast, it works in the sense that it detects things, but i don't manage to get the ray moving to the mouse position casting the ray "Aka : Ray from mouse perpendicular to screen plane"
I have already tried with
http://docs.godotengine.org/en/3.0/tutorials/physics/ray-casting.html
But it don't work
The setting,
Ortogonal camera
Rotated -30 degre on X
Translated to (0,5,5)
Script that creates the ray
func _ready():
# Create the RayCast
ray = RayCast.new()
ray.set_name("RayCast_cells")
# Atach the RayCast to the camera
camera = get_tree().get_root().find_node("Camera", true, false)
camera.add_child(ray)
# Configure the RayCast
ray.clear_exceptions()
ray.set_collision_mask(COLLISIONMASK)
ray.set_enabled(true)
set_physics_process(true)
And now the physicsprocess
func _physics_process(delta):
var mouse = get_viewport().get_mouse_position()
var from = camera.project_ray_origin(mouse)
var to = (from + camera.project_ray_normal(mouse))
ray.cast_to = to
ray.translation = from
if ray.is_colliding() :
print("found")