Change Sprite after specific conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
eloq
Posts: 4
Joined: Tue Apr 23, 2019 1:05 pm

Change Sprite after specific conversation

Post 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!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Sprite after specific conversation

Post 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}}
eloq
Posts: 4
Joined: Tue Apr 23, 2019 1:05 pm

Re: Change Sprite after specific conversation

Post 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?
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Sprite after specific conversation

Post 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.
eloq
Posts: 4
Joined: Tue Apr 23, 2019 1:05 pm

Re: Change Sprite after specific conversation

Post 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 584 times
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Sprite after specific conversation

Post 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.
eloq
Posts: 4
Joined: Tue Apr 23, 2019 1:05 pm

Re: Change Sprite after specific conversation

Post by eloq »

That was it! Thank you so much!
User avatar
Tony Li
Posts: 22056
Joined: Thu Jul 18, 2013 1:27 pm

Re: Change Sprite after specific conversation

Post by Tony Li »

Glad to help! :-)
Post Reply