GDScript compilation error : "Identifier is not declared in the current scope"

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rymfire

Hello world!

I just started using Godot Engine. Until here, I’m having fun during development of my game. I’ve been following this tutorial to do a very simple / first game.

During episode 4, I’ve encountered a compilation bug for my ‘’ script concerning my Mob : “Identifier ‘Mob’ is not declared in the current scope”. Here is my code :

func _on_MobTimer_timeout():
  var mob = Mob.instance()
  var direction = $MobPath/MobSpawnLocation.rotation
  mob.position = $MobPath/MobSpawnLocation.position
  direction += rand_range(-PI/4, PI/4)
  mob.rotation = direction
  mob.set_linear_velocity(Vector2(rand_range(mob._minSpeed, mob._maxSpeed), 0).reatated(direction))

The line that causes the problem is this one :

var mob = Mob.instance()

It must be a beginner error but I can’t find it… Can someone save me? :stuck_out_tongue:

:bust_in_silhouette: Reply From: kidscancode

The place where Mob is defined in that script is at the top:

export (PackedScene) var Mob

You then have to assign its value in the Inspector:

Drag Mob.tscn from the “FileSystem” panel and drop it in the Mob property under the Script Variables of the Main node.

I feel so dumb right now… x’)
Thanks mate!

Rymfire | 2019-06-07 18:48