I’m trying to implement a block erasure system where right-clicking removes a block at the mouse position using a raycast, but it’s not working as expected. The raycast doesn’t seem to detect collisions properly.
In player script
func _unhandled_input(_event: InputEvent) → void:
if Input.is_action_just_pressed(“rmb”):
diggingRaycast.target_position = (get_local_mouse_position().normalized()) * 25
diggingRaycast.force_raycast_update()
if diggingRaycast.is_colliding():
BlockManager.blockErase(diggingRaycast.get_collision_point())
In BlockManager script
func blockErase(pos: Vector2):
coords = tml.local_to_map(tml.to_local(pos))
tml.erase_cell(coords)