Cannot instantiate the class

Godot Version

4.4.1.stable.mono

Question

Hi, i am trying to follow book instructions but this error appears. Can someone explain me, what went wrong here?


Hi,

That codes works fine for me:

@export var bullet_scene: PackedScene = null

func _ready():
	var b = bullet_scene.instantiate()

Are you declaring the bullet_scene variable properly? Could you share the full code if you need more help?

1 Like

How do you declare the bullet scene? It’s not visible in your screenshot.

1 Like

Yeah that worked fine, when i added “= null” to declaration. TYVM

1 Like

Yeah, it was declaration problem.
Code from the book i used to declare the Scene with: @export var bullet_scene : PackedScene
wasn’t working without “=null”. Thank you for you response!

Using = null should not matter.
I believe you wrote @export var bullet_scene = PackedScene, with a = sign instead of :, right?

1 Like

I didn’t pay attention first, just replaced my code line with yours, but after you’ve mentioned it, i tried typing = instead of : and got my error again.
Next time i will pay more attention, sorry and TY again for your responces

1 Like