Hi guys,
I created a script that spawn 10 objects at the start of the game in random location.
extends Node2D
var n = 10
var object = load("res://Object.tscn")
func _ready():
randomize()
spawn()
func spawn():
for i in n:
var x = rand_range(0,300)
var y = rand_range(0,300)
var rand_pos = Vector2(x,y)
var object_instance = object.instance()
object_instance.position = rand_pos
add_child(object_instance)
How can I make sure that all of the objects are a certain distance from each other?
I want to leave a minimum distance between them.
Any help will be appreciated, thanks