Does anyone have a idea on a better way to implement this code:
var input_dir:float = signf(randf_range(-1,1))
The code block takes a random float between -1 to 1 and makes it the whole number -1 or 1
Is there a way I am missing that is easier?
Does anyone have a idea on a better way to implement this code:
var input_dir:float = signf(randf_range(-1,1))
The code block takes a random float between -1 to 1 and makes it the whole number -1 or 1
Is there a way I am missing that is easier?
Yours is not wrong per se.
You could make it easier to understand by doing this though:
var input_dir: float = [-1.0, 1.0].pick_random()
Never thought of using an array like that before, thank you!
This will help future me when coming back to the code