So, I’ve finished a tutorial recently and now I’m adding to the code, some more stuff. But I just can’t seem to get signals working properly. I have an autoload script with signals in it. And my goal with it is to have one scene emit the signal to another scene. But even though the emitting seems to work on the one scene and it appears that the signal is being connected on the other. It’s not doing the callable, that is the connect line, even though I have that function below it in the script. Here are some screenshots:
Well, it would be a little easier to see what you try to fix if you were to split the screenshots into 3 different pictures. It just doesn’t give enough info.
However, there are still some things you can try.
Check if you connected the signals properly
Check if the connected signals actually play out the code
Try recreating the error in a more simple manner and eaay to code environment
Don’t set breakpoints so that forum people know where the mostake is, since it doesn’t realy give you a line
These are a few ways to try and solve this, I eould also recommend getting rid of the 30ish errors in the debug manual, just makes it easier to look at…
If you find anything or can provide different screenshots, I would gladly try to help you.
Have a great day
One of the warnings you are getting is telling you that the parameter variables easy, medium, and hard are shadowing previously declared variables.
It should still work but I would rename the parameters so that the conflict and the warning goes away.
How do you determine that?
And how do you determine that?
We would like to see the signal definition please.
Your signal transmission logic is not entirely clear. Why are you passing all 3 arguments as a signal? Isn’t it easier to make 1 argument with a choice of the current difficulty and pass the value of this argument as the current difficulty in the signal?
Or maybe I didn’t understand, it’s difficult to understand from these screenshots what exactly you are trying to achieve.
For some reason, I couldn’t put three screenshots in one message, so that’s why I did the screenshot thing, I’ll put the screenshots in each a different reply. What I found out is that signal is being sent before the other scene gets readied. I do wonder how I could have this not happen though.
This is where the signal emitted, should play out this callable as this function
As you can see in the output, the signal is sent before it is connected. The reason it says connected at the very top is because you start at the main menu screen and then go to the settings menu screen and then back to the main menu screen.
To not have the signal sent before the other scene loads, maybe change the rady function.
You could for example try using an ‘await’ statement.
That way, you could await the scene to load and run the print statement after that.
You are connecting the signal in the _ready function of main menu scene.
If you are starting with the main menu scene then the connection should be happening first…unless the settings menu scene is a child of main menu scene.
Somehow the settings menu scene is being loaded first.
You don’t by any chance have the settings menu scene as an autoload?
The reason it isn’t readied is because the main menu scene has to re readied because one you switch to the settings menu scene, it’s deleted basically.
If a tree falls in the woods, and there’s no one there to hear it, does it make a sound?
The main menu scene isn’t going to handle a signal once you’ve deleted it. You need to have a scene outside of your menu screens, an autoload or a common root, that holds the data that needs to persist outside of their lifetimes. That scene should be listening for settings changes, and passing them to the gameplay/settings scenes when appropriate.
Unless you can start your game from the settings menu, there is no reason to unload the main menu.
Just hide it.
If you can go directly to the game from the settings menu then do what omc says and create a scene handler that doesn’t get unloaded.
i would make the settings scene an autoload that never gets unloaded
so it can be accessed from the pause menu.
a settings menu that can only be accessed in the main menu is good for a game jam but in a real game it would be annoying to have to give up some progress just to change the audio volume and the controls
Right now, this is just a build off of a tutorial that I did, so I’m just adding some things to it. However, I do agree with your point about the autoload and I’ll try that or another comment.
Thanks to all of guys! You 5 helped me solve this problem and clean up the code. I am just so thankful that you guys helped me out and given me more knowledge. Basically what I did was create a scene that has all the other scenes as children, then just signal up and call down!