Godot - Generate a random angle
This is how to generate a random angle using GDScript in Godot 4.
You can generate a random angle using randf()
.
Multiplying by 2 * PI gives you a random angle between 0 and 2π (0 to 360 degrees).randf()
has the following characteristics:
- Gets a random number between 0.0-1.0
var randomAngle = randf() * 2 * PI