I need to pick a random float from two ranges (-32.0, -200.0) and (32.0, 200.0).
I basically want to avoid the range(-32.0, 32.0).
I want to loop through the random ranges to get a new random float everytime.
You can use randf_range to get a random float from one of your ranges, and then use more randomness to negate it with a 50% chance.
func _ready():
# Initialize random generator - only do this once!
randomize()
func random_float():
# randomly generate a number from one of the two ranges
var f = randf_range(32.0, 200.0)
# randomly choose whether to negate it
var i = randi() % 2
if i == 0:
f = -f
return f