Browse Source

Merge pull request #6855 from abduelhamit/patch-1

Fix: progress_ratio expects a float, not an int
Max Hilbrunner 2 years ago
parent
commit
514956a227
1 changed files with 3 additions and 3 deletions
  1. 3 3
      getting_started/first_2d_game/05.the_main_game_scene.rst

+ 3 - 3
getting_started/first_2d_game/05.the_main_game_scene.rst

@@ -311,7 +311,7 @@ Note that a new instance must be added to the scene using ``add_child()``.
 
         # Choose a random location on Path2D.
         var mob_spawn_location = get_node("MobPath/MobSpawnLocation")
-        mob_spawn_location.progress_ratio = randi()
+        mob_spawn_location.progress_ratio = randf()
 
         # Set the mob's direction perpendicular to the path direction.
         var direction = mob_spawn_location.rotation + PI / 2
@@ -343,7 +343,7 @@ Note that a new instance must be added to the scene using ``add_child()``.
 
         // Choose a random location on Path2D.
         var mobSpawnLocation = GetNode<PathFollow2D>("MobPath/MobSpawnLocation");
-        mobSpawnLocation.ProgressRatio = GD.Randi();
+        mobSpawnLocation.ProgressRatio = GD.Randf();
 
         // Set the mob's direction perpendicular to the path direction.
         float direction = mobSpawnLocation.Rotation + Mathf.Pi / 2;
@@ -371,7 +371,7 @@ Note that a new instance must be added to the scene using ``add_child()``.
         godot::Node *mob = mob_scene->instance();
 
         // Choose a random location on Path2D.
-        _mob_spawn_location->set_progress_ratio((real_t)_random->randi());
+        _mob_spawn_location->set_progress_ratio((real_t)_random->randf());
 
         // Set the mob's direction perpendicular to the path direction.
         real_t direction = _mob_spawn_location->get_rotation() + (real_t)Math_PI / 2;