Godot Version
4.2.1
Question
I’m encountering an issue with item pickup that started occurring after I implemented the skill menu. This problem didn’t exist previously. The skill menu and item pickup systems aren’t connected in any way. When I test the scene in isolation, the crash doesn’t occur. However, when I run the full project and reach that scene, the game crashes upon picking up the item and if I just connect the menu to the level, instead of the skill menu, the bug and crash won’t happen. Note that the item is a child of the map object. also, by just adding the skill menu scene, there will be 189 warnings.
this is the crash error:
Invalid set index ‘texture’ (on base: ‘Nil’) with value of type ‘CompressedTexture2D’.
So, something in that code is trying to set foo.texture = bar
, and foo
is Nil
. That probably means either:
- you have a
var foo
that is never initialized
- you have a
var foo
that was initialized to something invalid
Reading the warnings would be a good idea. What do they say?
1 Like
its 189 warnings… basically they are warnings for every script possible. to Save script which i just made it and not using for now, to the player’s gun function… if we just skip the skill menu, none of the warnings happen
Can you give me an example of the warnings? They may be relevant here.
1 Like
I think the problems are related. It looks like that scene is screwing up your node hierarchy somehow, or is being added somewhere that changes the node hierarchy such that a bunch of stuff doesn’t bind successfully. The crash you’re getting is probably an attempt to use one of those things that didn’t bind.
1 Like
ok, so skill menu is screwing up the hierarchy… but the code isnt that complicated.
What does the node hierarchy look like for your Gendermaria
scene?
1 Like
I’m assuming you added the skill menu in:
$/root/Gendermaria/TileMap/Player/
Since all the warnings you list have that in their root. Is there maybe a name clash, or is your skill menu becoming a parent for some of these things?
no no, when you click the new game, you get to the skill menu
scene. choose the abilities you want, and when your points are 0, you get to the gendarmerie
level
Ah, ok, then what’s probably happening is that all that stuff isn’t in the scene tree when the @onready
vars are populated, which is leaving you with a bunch of stuff that’s not properly initialized. One of those things is then exploding when something tries to set a value on it.
There are probably 188 other crashes waiting to happen if you get past this one. I think you need to sort the errors out.
My suggestion for a quick fix is, have the gendarmarie
level in the hierarchy, but hidden. When you want to switch to it, hide()
the skill menu and show()
the game level.
1 Like
or just queue free it. im gonna try it
1 Like