Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove_child on a dialog make it crash #1

Open
ParisRomane opened this issue Aug 2, 2022 · 4 comments
Open

Remove_child on a dialog make it crash #1

ParisRomane opened this issue Aug 2, 2022 · 4 comments

Comments

@ParisRomane
Copy link

Hello everyone !
I just tried dialogic for the first time a week ago, I love it.

My problem is : i want to be able to pause dialog and get back to it, without having to end dialog and play it back from the start.
For example, i want to be able to open a menu or an inventory when we are in a middle of a dialog.

I have tried everything i can to pause dialog. Nothing works. I even tried to do it brutally, with remove_child(dialog) and add_child(dialog).
That is when i find a bug i believe :
remove_child(dialog) -> "Attempt to call 'get_visible_rect' in base 'null instance' on a null instance"

Describe the bug
remove_child(dialog) make the game cash, with "Attempt to call 'get_visible_rect' in base 'null instance' on a null instance" in DialogNode.gd
(also btw, is there a way to pause dialog ?)

To Reproduce
Steps to reproduce the behavior:

  1. create a dialog, and instance it normally -> add_child(dialog)
  2. While the dialog isn't finished, do remove_child(dialog)
  3. See error ("Attempt to call 'get_visible_rect' in base 'null instance' on a null instance")

Expected behavior
I expected to just remove the dialog. but it's seems like it is still working. But it can't so it crash.

Screenshots
the result of the crash :
bug

System (please complete the following information):

  • OS: linux
  • Godot Version: 3.4.4
  • Dialogic Version: 1.4.3

Solutions

Workaround
Nothing that i tried works to get the dialog to pause.
We can end dialog and play it back from the start tho.

Possible fixes
No idea yet.

@Jowan-Spooner
Copy link
Collaborator

Jowan-Spooner commented Aug 2, 2022

Hmm... it seems like the DialogNode doesn't like to be outside of the tree after connecting to the viewport. Removing nodes from the tree without deleting them is a unusual move, so this has never happened in testing.

If you just want to delete the node do dialog.queue_free().

For pausing: have you considered using godot's pause system? I understand that might not work for your project tho.

It's unlikely we will make a fix, as we are putting most efforts into dialogic 2.0.
Here are possible "hacky"-quick-fixes:

  • To make remove_child() not result in an error you could try adding if !is_inside_tree(): return at the start of the resize_main() method. This might not work if other parts of the script assume they are inside the tree too.

  • if pausing only means not getting input (and thus not continuing) then you could modify the _input() method of the DialogNode.gd. E.g. if you have an autoload add a var dialog_paused = false flag and check for that flag before collecting input. Now you can set that flag to disable input on the dialog node.

@ParisRomane
Copy link
Author

Thanks a lot for the answer !
Godot pause system doesn't really work as i want.
Thanks a lot for the suggestions, they are really good ! I will try to create my pause fonction tomorow

@ParisRomane
Copy link
Author

ParisRomane commented Aug 3, 2022

I have followed your advice. I might not have done it in the cleanest way.
If someone need the same feature this is what i have done :
in dialog_node.gd i add ->

var paused = false

func set_paused(pause):
	paused = pause

func get_paused():
	return paused

func _input(event: InputEvent) -> void:
	if paused :
		return
	[...]

in canvas_dialog_node.gd i add :


func set_paused(pause):
	dialog_node.set_paused(pause)
	if pause : # those line hide visually the dialog
		dialog_node.hide()
	else :
		dialog_node.show()

func get_paused():
	return dialog_node.get_paused()

Now i can have open a menu (or inventory) in the middle of a dialog. thanks again ! 👍

@Jowan-Spooner Jowan-Spooner transferred this issue from dialogic-godot/dialogic Apr 10, 2024
@zaknafean
Copy link
Collaborator

This was completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants