I have this weird situation and I do not know what could be causing it.
As explained in some of my previous posts, I am developing a card game. I have two screens (each is a scene). In the first one I make the player pick a card deck out of three possibilities. As soon as the player does so, I switch to the other scene, where the card game actually takes place.
The problem is with the first scene (the main one, the one that loads when I click F5 in the editor). For some reason, aside from the stuff that is supposed to be in the first screen, I also get a specific bit stuff that should only be in the second one. More specifically, I get the framework of an enemy card which should only load once the faction has been picked and the cards are dealt. The enemy card is a scene in itself that I instantiate several times in the second screen, so I believe the problem seems to be more or less localized. However, I cannot find it. The code in the first screen does not refer to that scene at all.
I’m guessing it’s a really simple thing, like having checked one wrong box in the editor. Has anybody encountered this kind of problem before?
Sorry I see mystery behavior all the time . How do you load the 2nd scene? Load or or preload. ? When do you instance? Any idea of the section of code causing this? Can you post it?
Thanks very much for your answer. Posting the code would take several pages , because I cannot pinpoint the offending line. However, I can answer your other questions:
The second screen preloads two scenes, the player_card and the enemy_card. If that is the problem, it’s interesting that only the enemy_card shows up in the selection screen.
Both cards are instanced in functions called from the _ready function in the second screen. They are not even referred to in the first screen.
EDIT. As a test, I have commented out all three scenes that make up the second screen and run the game. The enemy_card keeps being instantiated in the selection screen, even though it theoretically does not exist.
SECOND EDIT. As another test, I have completely deleted all three scenes that make up the second screen and run the game. Now I get this error in the debugger:
E 0:00:00:0636 instantiate: Failed to instantiate scene state of “res://card_base_enemy.tscn”, node count is 0. Make sure the PackedScene resource is valid.
<C++ Error> Condition “nc == 0” is true. Returning: nullptr*