When using the Dialogue Manager addon on Godot, I am trying to run a function to change the sprite of a character. My function look like this under my character script:

func ace_change_sprite(index):

and my dialogue looks like this:

~ start
: test
Ace: Hey Miyu!
do emit("AceUpdateSprite",3)

When I run this, it prints the "EEE" but it doesn't update the Sprite. My character script is AutoLoaded and I have tried using signals, but still got the same result of "EEE" being printed but nothing else happening.

My change_sprite function is this:

func change_sprite(index):
    $Sprite.texture = load(sprites_path + character_name + str(index) + ".png")

It works when I call it within the player script, changing the sprite, but when I call it outside it doesn't seem to work.

  • \$\begingroup\$ This is wild speculation, but: are you sure there is only one character in the scene? I'm thinking there could be two (one autloaded, and one in the scene proper) and only one of them is getting the signal, and it is not the one you are looking at. \$\endgroup\$
    – Theraot
    Sep 28 at 3:16
  • \$\begingroup\$ @Theraot I have only added once Character scene to it. Node Structure: Node -Characters (Node2D) - - Ace (Node2D) Ace is the character. Should I add the character through GDScript? \$\endgroup\$ Sep 28 at 3:30
  • \$\begingroup\$ I would assume that the problem is that the change_sprite method either doesn't work or doesn't work the way you think it does. But I can't find a method with that name anywhere in the official Godot reference, so I assume it's a function that you either wrote yourself or that is provided by the dialogue manager addon. If it's your own function, please post the sourcecode. If it's a 3rd party function, please link to the documentation. \$\endgroup\$
    – Philipp
    Sep 28 at 9:46
  • \$\begingroup\$ @Philipp I have updated the question with the needed information. Also I know my function works since when I call it inside the character script, it changes the sprite. \$\endgroup\$ Sep 28 at 13:08
  • 1
    \$\begingroup\$ could you try to preload the texture and saving it in an array? So it does not get loaded in the signal itself? \$\endgroup\$
    – Bugfi5h
    Sep 29 at 19:20


You must log in to answer this question.

Browse other questions tagged .