I'm working on a script that returns the position on a gridmap in 3d from a mouse click. Here's my code:
extends Camera
var target: Spatial
onready var ray := $RayCast
func _input(event: InputEvent) -> void:
if event is InputEventMouseButton or event is InputEventScreenTouch:
if event.pressed:
_select_target(event.position)
func _select_target(position: Vector2) -> void:
var to = project_local_ray_normal(position) * 10000
ray.cast_to = to
ray.force_raycast_update()
print("click")
if ray.is_colliding():
var point = ray.get_collision_point()
print(point)
So, this code works flawlessly except for one thing: It does not work with an orthogonal camera, which is what I need it to do. From what I can dig up in the docs I don't know why or how to fix it since project_local_ray_normal should work in either camera mode(i think).
Anyone have insight?