Signal is firing but main scene not detecting it

Godot Version

4.2.1 stable

Question

Hi all,
I have two issues,
first, I followed a few tutorials on creating scene transitions and I can’t seem to get the fade in and out animation to play. I create a scene with just a colorrect and animation player that has the code to play the animation. In it, it has a function that will first call the animation and then transition to the next scene. I Autoloaded it so it can be called in the main scene to play the scene when it gets a signal from another scene. Now, the scene changes works, but it won’t play the animation. This lead to me redoing the project to clean up the code and now I have a second problem.

So, I modularized my code better(at least I think I did) on everything but the main scene. The goal is to have main scene would load the starting modular scene(starting level and levels as you get farther), which has a signal that will emit when that scene is done back to the main scene. But the issue is, the modular scene is emitting the signal, but the main scene isn’t receiving it, it’s just receiving an empty object. I tried instancing it and it didn’t work, the scene is Autoloaded so it isn’t that.

If I manually add the scene to the main it works either through add child or adding it in the scene(the animation still doesn’t play though). Not sure what’s going wrong.

https://drive.google.com/drive/folders/12N2JhZS_g9wB9iB_jfJnJqX4Ifba0D4K?usp=drive_link

Do you mind sending the link of the tutorial you used?

I followed a few, trying to get it to work.
I can’t post any more links because i’m new. I followed this one and a few ones on youtube that specify godot 4.

Did you name everything right?

Yeah, I just triple checked the names.

Was wondering if there was anything else that could go wrong? I can’t continue the project until I fix this issue.

I’ve downloaded your vn template and opened it now I’m having trouble figuring out which signal you’re talking about. Can you tell me which scene I’m supposed to be looking at and what signal is firing?

EDIT:

Okay so I see your scene_finished signal and see it emitting, but I don’t see where this signal is connected.

1 Like

It should be on line 30 in the VN main using the connect method

I have a commented out line that says

		#Fade.transition()

Which might work because you have it in an autoload, but that’s not using signals.

On line 30 of VN Main, i’m using the connect method to get the signal
From what I understand, as long as the scene is autoloaded, if you instance it, I should be able to access the signal when it’s loaded into the main scene

trans_scene.scene_finished.connect(transit)

Oh whoops I was wrong file. On line 20-22 I see:

	#trans_scene.scene_finished.connect(self.print("signal working"))
	#print(trans_scene.scene_finished.connect(transit))
	#print(trans_scene.scene_finished.connect(self.transit)

There’s a lot of commented out code here and it’s getting a bit confusing going back and forth through everything. Let me see if I can reconstruct this. Give me a bit.

1 Like

Thank you! I was trying many ways to get it to work, sorry about all the commented out code.

Sorry that took so long. Here’s a zip with the project I redid.

I’m probably done with stuff for tonight, but take a look at this and see if it makes sense to you. I’ll be back on tomorrow to answer any questions.

I still don’t think this is the best setup for anything other than a linear VN, but we can talk about that later.

1 Like

Thank you! I will dive into it later tonight and ask any questions tomorrow!

Okay I’m back and I’ll try to break down what I did and changed so you can hopefully understand.

There are now two singletons. StoryManager and SignalManager. Right now they are both only doing one thing each, but VN can become complicated and need a lot of things to happen and you can extend these.

StoryManager loads up your json and keeps track of your place. This format only really allows for linear VNs, but I was copying your current style. This might be completely fine for your project. Since it’s a singleton, anything can access it with StoryManager.story or StoryMangager.place.

SignalManager manages your signals. Right now it only has one signal called scene_finished that handles 2 different transitions and a new background. You could change this from a background to a new scene is that suited your game more.

To implement this transition I changed your JSON format a bit. You’ll see that you now have a line that says, {"id": 2, "name": "Brenda", "Dialogue": "it works!", "end_scene": "Scene2"}.

In vn_canvas.gd under _progress_story() you now have the following code:

func _progress_story() -> void:
	if "end_scene" in StoryManager.story[StoryManager.place]:
		SignalManager.scene_finished.emit("fade_to_black", "fade_from_black", "res://art/1080p.jpg")
		await %Transitions.animation_finished

This is hard coded as an example, but you could easily add the background path in the json and pull it out from there. The fade_to_black and fade_from_black are the names of the animations in the animation player called Transitions

You’ll see in vn_canvas.gd that I connect the signal in the _ready() function with SignalManager.scene_finished.connect(_on_scene_finish)

1 Like

Thank you so much for the help! Looking at the code I believe I can extend it so it’s more customizable.
So, it looks like the transitions weren’t working because of input issues, which is the only thing I can think of. I see it being taken care of in the _on_scene_finished function. I like the structure of everything.
It looks like it it’s better to have a single script deal with the signals and story? So, in the future, I could create another manager for lets say the characters or sounds or the such?
The JSON i was going to use to deal with all the assets, including the story with links to the assets and everything, this one was just I made to see if I could get dialogue to show up so the structure for it isn’t really a structure.
I still don’t know why my old code didn’t work for the signals, it seems like for the transitions it was still getting the mouse click even though I thought i turned that off based on a tutorial I was following, but I’ll just assume my newbie eyes missed something.
Once again thank you!

No problem. Because the code I had was in a weird state, it was hard for me to decipher what code was supposed to be in there and now so I’m not 100% sure why your signals weren’t working. I did notice you had your code in the _process() function which runs every engine tick and I’m wondering if that was part of the problem. Generally you only want to use _process() for things that need to happen as quickly as possible every frame…

It looks like it it’s better to have a single script deal with the signals and story?

Maybe. It really depends on a lot of things. I personally like doing it this way because I find it easier, but there are plenty of people who will tell you that using a signal manager makes it harder for them to keep track of their signals. In the end you should try different ways and see what works best for you.

So, in the future, I could create another manager for lets say the characters or sounds or the such?

That might be a viable solution. You could also look into using addons to help you with this like Dialogic

I had a lot of code in the _process() function because I thought only the ready and process() is the only way to execute a function in a script? I’m still working my way around the program though.

Got it, the purpose of this project was to figure out the Godot workflow. I like the signal manager since it actually works for me lol.

I’ll look into that!
Once again thanks for all the help!

I thought only the ready and process() is the only way to execute a function in a script?

There are a lot of functions that happen in a script. _input, _unhandled_input. _process, and _physics_process all are checked every frame and will run code directly inside of them.

You can also call functions in your script externally as the signals do. I’ll stop replying to this topic since we’re getting off topic, but you can always ask more questions as you run into problems.

Good luck!

Gotcha. I tried searching for which functions automatically run, but came up short. I’ll look into those!