0 votes

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 'Main.gd' 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? :p

in Engine by (15 points)

1 Answer

+3 votes
Best answer

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.
by (20,485 points)
selected by

I feel so dumb right now... x')
Thanks mate!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.