Apply random linear velocity to a rigid body 3D when it spawns.
I have a rigidbody that spawns and I want it to shoot randomly.
func _ready():
linear_velocity.y = get_random_f_amount(5, 10)
linear_velocity.z = get_random_f_amount(-2.5, -1.5)
linear_velocity.x = get_random_f_amount(-2.5, -1.5)
func get_random_f_amount(min, max):
var rng = RandomNumberGenerator.new()
rng.randomize()
var to_return = rng.randf_range(min, max)
return to_return
This works, but it shoots only to the left.
Am I doing this wrong ?
Thanks !