this post was submitted on 17 Sep 2023
13 points (93.3% liked)

Godot

5888 readers
54 users here now

Welcome to the programming.dev Godot community!

This is a place where you can discuss about anything relating to the Godot game engine. Feel free to ask questions, post tutorials, show off your godot game, etc.

Make sure to follow the Godot CoC while chatting

We have a matrix room that can be used for chatting with other members of the community here

Links

Other Communities

Rules

We have a four strike system in this community where you get warned the first time you break a rule, then given a week ban, then given a year ban, then a permanent ban. Certain actions may bypass this and go straight to permanent ban if severe enough and done with malicious intent

Wormhole

!roguelikedev@programming.dev

Credits

founded 1 year ago
MODERATORS
 

When reloading the same scene which is currently the current_scene, the script attached to the root node of the scene disappears. Every other script within the scene still appears. I tested this, by putting this:

func ready(): print("[DEBUG] I have a script!") into the script of the root node of the scene. Is this a known issue, or am I doing something wrong?

I'm reloading the scene with: @onready var startMenu:PackedScene = preload("res://ui/start_menu.tscn")

func _on_reload_pressed(): get_tree().change_scene_to_packed(startMenu)

Using the latest stable version

you are viewing a single comment's thread
view the rest of the comments
[–] Smorty@lemmy.blahaj.zone 1 points 1 year ago (1 children)

When switching to get_tree().change_scene_to_file() the same thing accurs. The only errors I'm getting are the ones related to other Nodes trying to interact with the script, which isn't there. Here an example of a button, trying to call a function, as it is connected to it via a signal: E 0:00:05:0925 emit_signalp: Error calling from signal 'pressed' to callable: 'Node::_on_reload_pressed': Method not found. There are no other errors when switching the scene like this.

For further clarification, here is the scene I'm in:

The script attached to StartMenu does not work, but the script attached to Control does. Again, this only occurs when changing the main scene. I defined this scene as the main scene in the project settings, and the first time it loads (on startup of the game) it works no problem. Just on that second load, the get_tree().change_scene_to_file() maybe somehow messes it up.

[–] simple@lemm.ee 2 points 1 year ago (1 children)

Seems like you might have an issue with how you set up the signals. So does _on_reload_pressed work before switching scenes, then stops working after switching? Are the signals connected to Control or StartMenu?

Also if you send me the project I can take a quick look.

[–] Smorty@lemmy.blahaj.zone 1 points 1 year ago

The button is connected to then StartMenu. I'll see how I can send you the project... never used gitlab or similar services before.