CollisionShape2D does not seem to have any is_colliding() function, did you mean Area2D.get_overlapping_bodies().size() > 0
?
You could do something like this:
var my_area: Area2D
var my_raycast: RayCast2D
var options := [preload("res://..."), ...]
func _ready():
my_area = $Area #Replace with actual path to the nodes
my_raycast = $Raycast
my_area.connect("body_exited", self, "check_count")
func check_count(_body_which_exited):
if my_area.get_overlapping_bodies().size() > 0:
var chosen_tilemap := randi() % options.size()
var new_tilemap: Node2D= options[chosen_tilemap].instance()
#Pick one of the two lines
new_tilemap.position = my_raycast.position #For the actual raycast's position
new_tilemap.position = my_raycast.get_collider().position #For the position of what it collides with.
add_child(new_tilemap)
Edit: wrote my_area.get_overlapping_bodies instead of my_area.get_overlapping_bodies().size().