From 8debbc2a72f0645c34784e7221a01df01c3341a6 Mon Sep 17 00:00:00 2001 From: Mohamed Koubaa Date: Fri, 10 Jan 2025 12:53:13 -0600 Subject: [PATCH] Move position setting code to be before direction in The main game scene (#10452) Handle the position before the direction to make the code easier to follow. --- getting_started/first_2d_game/05.the_main_game_scene.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/getting_started/first_2d_game/05.the_main_game_scene.rst b/getting_started/first_2d_game/05.the_main_game_scene.rst index ff4c922b2..2087cd474 100644 --- a/getting_started/first_2d_game/05.the_main_game_scene.rst +++ b/getting_started/first_2d_game/05.the_main_game_scene.rst @@ -202,12 +202,12 @@ Note that a new instance must be added to the scene using ``add_child()``. var mob_spawn_location = $MobPath/MobSpawnLocation mob_spawn_location.progress_ratio = randf() + # Set the mob's position to the random location. + mob.position = mob_spawn_location.position + # Set the mob's direction perpendicular to the path direction. var direction = mob_spawn_location.rotation + PI / 2 - # Set the mob's position to a random location. - mob.position = mob_spawn_location.position - # Add some randomness to the direction. direction += randf_range(-PI / 4, PI / 4) mob.rotation = direction