Random spawning spheres in GridMap

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

I’m trying to randomly spawn objects inside gridmap box(lets say its like an aquarium or box). Unfortunately I don’t have any results.
Here is code from my Scene script

extends Spatial
const bb = preload(“res://Boid.tscn”)
const gridmap = preload(“res://GridMap.tscn”)
func _ready():
spawnBoids(50)

func spawnBoid():
var bo = bb.instance()
add_child(bo)
bo.transform.origin=Vector3(100,100,100)
bo.direction= Vector3(round(randf()),round(randf()),round(randf()))

func spawnBoids(count): for i in range (count): var x = rand_range(100,500) var y = rand_range(100,500) var z = rand_range(100,500) var bo = bb.instance() add_child(bo) bo.transform.origin.x = x; bo.transform.origin.y = y; bo.transform.origin.z = z; bo.direction = Vector3(round(randf()),round(randf()),round(randf()))

Im new to the godot, does anyone have any idea what im doing wrong?
I also tried to implement this into GridMap script, also without any result