+4 votes
E 0:00:01.131   can_instance: Cannot instance script because the class 'Interface' could not be found. Script: 'res://Interface.cs'.
  <C++-Fehler>  Method failed. Returning: __null
  <C++-Quellcode>modules/mono/csharp_script.cpp:2942 @ can_instance()
  <Stacktrace>  :0 @ Int32 Godot.NativeCalls.godot_icall_1_187(IntPtr , IntPtr , System.String )()
                SceneTree.cs:637 @ Godot.Error Godot.SceneTree.ChangeScene(System.String )()
                SceneChanger.cs:24 @ Boolean 

I don't know why it says class can not be found. The node with that script is in the scene tree. There are also no compiler errors or anything. Any ideas?

Godot version 3.2.4 beta4 official
in Engine by (82 points)

2 Answers

0 votes
Best answer

looks like an old question but since I't the first in google It might still be useful.

I don't know exactly what is happening here, but I have a similar problem. I found that if the constructor code (or field initialization) raise an exception this is the error you get.
moving the suspicious code to _ready helped me discover the hidden exception

by (46 points)
selected by
+1 vote

I had this same issue, but I managed to find and fix it.

From what i can tell, it happens when the name of the script(i.e. "PlayerMovement.cs"), doesn't match the "class name" (i.e. "public class Player : Node").

Just replace the "class name" with the file name.
(I.E. "public class PlayerMovement : Node").

Hope this helps.

by (16 points)
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 Frequently asked questions and 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.