From c9c280491f2113ed3ee7f39b9f5457435ea85117 Mon Sep 17 00:00:00 2001 From: Mikhail Aristov <12281487+MikhailAristov@users.noreply.github.com> Date: Sun, 28 Jan 2024 14:57:01 +0100 Subject: [PATCH] randomize bottle --- godot/scenes/objects/bottle.gd | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/godot/scenes/objects/bottle.gd b/godot/scenes/objects/bottle.gd index 2dc2fba..26bb665 100644 --- a/godot/scenes/objects/bottle.gd +++ b/godot/scenes/objects/bottle.gd @@ -10,6 +10,12 @@ var is_hidding: bool # Called when the node enters the scene tree for the first time. func _ready(): tim_global_position = get_node("/root/IngameScene/Stage/Tim/ThrowPoint").global_position + tim_global_position += _random_inside_unit_circle() * 23 + rotation_degrees += randf() * 360 + +func _random_inside_unit_circle() -> Vector2: + var theta : float = randf() * 2 * PI + return Vector2(cos(theta), sin(theta)) * sqrt(randf()) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta):