Page 1 of 1

Change Sprite after specific conversation

Posted: Wed Apr 24, 2019 1:10 pm
by eloq
I am using the Set Component Enabled and Set Animator State on Dialogue to change my character controller's sprite, however I wish to have it restricted to only one conversation, as right now the sprite changes when any conversation is started. Is there a way to do this, or a better way to do this? I attempted using a second dialogue database but that was not working, and also attempted to use the sequencer but could not make it work. I can also post images and code if needed, thank you to anyone who can help!

Re: Change Sprite after specific conversation

Posted: Wed Apr 24, 2019 2:28 pm
by Tony Li
Let's see if we can get the sequencer working for that conversation.

As an example, let's say your player GameObject is named "Player". It has a component named Glow that you want to enable. In a dialogue entry node's Sequence field, use the SetEnabled() sequencer command:

Code: Select all

SetEnabled(Glow, true, Player)
Let's also say that the player's animator has a state named Berserk. Use the AnimatorPlay() sequencer command to change the animator to this state:

Code: Select all

AnimatorPlay(Berserk, Player)
You'll probably also want to play whatever the default sequence is, which typically delays the line to give the player time to read it. So the final Sequence field might be:

Code: Select all

SetEnabled(Glow, true, Player);
AnimatorPlay(Berserk, Player);
{{default}}

Re: Change Sprite after specific conversation

Posted: Mon Apr 29, 2019 3:34 pm
by eloq
Thank you for your reply! I added in the command within the sequence area with the correct names for my project, and it does not change anything. Is there something else I would need to do?

Re: Change Sprite after specific conversation

Posted: Mon Apr 29, 2019 3:47 pm
by Tony Li
Let's figure out why it's not working. Please temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. Then play through that dialogue entry node.

Each command -- such as SetEnabled(Glow, true, Player)-- will have two lines in the Console window. The first shows the lines as the Dialogue System understands it. The second shows when the Dialogue System is actually running the command. Please paste both lines into a reply.

Re: Change Sprite after specific conversation

Posted: Mon Apr 29, 2019 3:55 pm
by eloq
Screen Shot 2019-04-29 at 3.53.50 PM.png
Screen Shot 2019-04-29 at 3.53.50 PM.png (101.98 KiB) Viewed 583 times

Re: Change Sprite after specific conversation

Posted: Mon Apr 29, 2019 4:10 pm
by Tony Li
Change this:

AnimatorPlay(Idle, Character)

to this:

AnimatorPlay(Idle, speaker)

The warning means the Dialogue System can't find a GameObject named "Character". The special keyword "speaker" tells the Dialogue System to use the current speaker's GameObject; it doesn't matter what it's named in this case.

BTW, it looks like your GameObject may have a blank space at the end of its name, such as "Character " instead of "Character". This might be why the Dialogue System can't find it.

Re: Change Sprite after specific conversation

Posted: Mon Apr 29, 2019 4:16 pm
by eloq
That was it! Thank you so much!

Re: Change Sprite after specific conversation

Posted: Mon Apr 29, 2019 4:18 pm
by Tony Li
Glad to help! :-)