I need to make a node spawn randomly through a set area, I have been fiddling with it four hours now please help!

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By BreamkillerX

I have a node that I need to duplicate randomly on the map every 10 or so seconds.

:bust_in_silhouette: Reply From: exuin

Not tested, but try this:

var node_path = preload("res://path_to_node.tscn")

func _ready():
    randomize()

func make_node():
    # Call this function every 10 or so seconds using a timer
    var node = node_path.instance()
    add_child(node)
    node.position = Vector2(rand_range(min_x, max_x), rand_range(min_y, max_y))