Browse Source

Use explicit casting for `MobScene.Instance()` in 3D game tutorial (#5021)

Implicit casting of "Godot.Node" to "Mob" is not allowed,
so I tried explicit casting and it worked.
Verizane 4 years ago
parent
commit
b9b8b32435
1 changed files with 2 additions and 2 deletions
  1. 2 2
      getting_started/first_3d_game/05.spawning_mobs.rst

+ 2 - 2
getting_started/first_3d_game/05.spawning_mobs.rst

@@ -255,7 +255,7 @@ Let's code the mob spawning logic. We're going to:
     public void OnMobTimerTimeout()
     {
         // Create a mob instance and add it to the scene.
-        Mob mob = MobScene.Instance();
+        Mob mob = (Mob)MobScene.Instance();
 
         // Choose a random location on Path2D.
         // We stire the reference to the SpawnLocation node.
@@ -312,7 +312,7 @@ Here is the complete ``Main.gd`` script so far, for reference.
 
         public void OnMobTimerTimeout()
         {
-            Mob mob = MobScene.Instance();
+            Mob mob = (Mob)MobScene.Instance();
 
             var mobSpawnLocation = GetNode<PathFollow>("SpawnPath/SpawnLocation");
             mobSpawnLocation.UnitOffset = GD.Randf();