Search code examples
game-enginegame-developmentgodotgdscriptgodot4

Sprite3D texture turns to <Object#Null> when I change it thru code in Godot 4.1.1


I'm making a 2.5D tower defense game with bloons in Godot. (All code and scenes are on my github). (Also I fixed my git so the repo is working now) My Bloon scene consists of a Node3D and a Sprite3D for the Bloon, and when I instantiate the Bloon (in code) the Node3D and Sprite3D are in the scene tree, but it doesn't show the sprite.

I tried changing the sprite after instantiating the scene, but still nothing. I also tried hiding all other objects, but still, nothing. J was expecting that the Bloon sprite would show at 0,0,0 but it didn't.


Solution

  • I found the answer: turns out you need to use preload() instead of load().