Skip to content

Loading errors when using layered portraits #2683

@ReNhoSoft

Description

@ReNhoSoft

The problem

Describe the bug
When attempting to load a state using a character with a layered portrait with an active text, the game crashes with error

change_speaker: Attempt to call function '_highlight' in base 'null instance' on a null instance.

If the dialogue is from a character that hasn't joined the scene, or if the character is using a simple portrait the error doesn't occur.

To Reproduce
Steps to reproduce the behavior:

  1. Create new project with a fresh install of Dialogic
  2. Create a test character using a layered portrait. Leave the default structure in place, only replace the texture of the 'Layer1' node with a sample one.
  3. Create a timeline, join the test character and have them speak
join test_character center
test_character: Hi
  1. While playing the timeline, right after the dialog appears, save and load
  2. Dialogic throws an error
E 0:00:05:694   change_speaker: Attempt to call function '_highlight' in base 'null instance' on a null instance.
  <GDScript Source>subsystem_portraits.gd:707 @ change_speaker()
  <Stack Trace> subsystem_portraits.gd:707 @ change_speaker()
                subsystem_portraits.gd:50 @ load_game_state()
                DialogicGameHandler.gd:405 @ <anonymous lambda>()
                DialogicGameHandler.gd:411 @ load_full_state()

To test I used the following script on the root node:

extends Node2D
func _input(event: InputEvent):
	if event is InputEventKey and event.keycode == KEY_ENTER and event.pressed:
		if Dialogic.current_timeline != null:
			return
		Dialogic.start('test_timeline')
		get_viewport().set_input_as_handled()
	
	if event is InputEventKey and event.keycode == KEY_F1 and event.pressed:
		Dialogic.Save.save();
		get_viewport().set_input_as_handled()
	
	
	if event is InputEventKey and event.keycode == KEY_F2 and event.pressed:
		Dialogic.Save.load();
		get_viewport().set_input_as_handled()

Expected behavior
The system should restore the save without issues

Screenshots
Exception thrown when attempting to load
Image

Warnings and errors at the time of the exception
Image

System (please complete the following information):

  • OS: Linux Mint 22.2 Cinnamon
  • Godot Version: 4.5
  • Dialogic Version: 2.0-Alpha-18

Solutions (workaround)

As far as I can tell, Dialogic is attempting to call highlight on portraits that have not yet been fully instantiated as theyre not yet part of the node tree. If I let execution continue the nodes are eventually created and the rest of the state loads as expected

As a workaround I've commented lines 702-707 of subsystem_portraits.gd, since I have no need for portrait highlights.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions