I am very new to Godot and generally making games but I have this tiny problem.
I am making an Asteroids type game and the basics of it are. I destroy an Asteroid and it splits into multiple smaller versions with random vectors.
This works perfectly fine until I try to run it in a browser. In the browser, the vectors for each separate instance are exactly the same every single time.
Here is my code for spawning them
var ma = med_asteroid.instance()
var ma2 = med_asteroid.instance()
ma.spawn(position)
ma2.spawn(position)
get_parent().call_deferred("add_child", ma)
get_parent().call_deferred("add_child", ma2)
Here is the spawn code
func spawn(pos):
var rng = RandomNumberGenerator.new()
rng.randomize()
position = pos
rotation = rng.randf_range(PI,-PI)
speed = rng.randi_range(ba_speed_min, ba_speed_max)
velocity = Vector2(speed, 0).rotated(rotation)
Thank you.