Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Bibin | |
Old Version | Published before Godot 3 was released. |
Reply From: | avencherus |
randomize() to set a seed
randf() for a random float 0.0-1.0
randi() for a random int 0-1
Some of the code might look like:
var max_speed = 100
randomize()
var speed = randf() * max_speed
object.set_speed(speed)
How you implement set_speed is up to you. Most likely take a unit vector of it’s direction, and multiply the speed value into it’s X and Y components.