Switching Character portraits in script

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Switching Character portraits in script

Post by rykaan »

Hi Tony,

I'm attempting to switch the default portrait of a character during a conversation via script, then using the 'SetPortrait(CHARACTERNAME, default)' sequence to refresh to the newly updated portrait. It works for a single line of dialogue, but then the portrait is missing in the following line. The documentation reads that the 'SetPortrait' sequence would keep the change until changed again, so I'm confused as to why this wouldn't remain for the whole conversation.
Switch Snake Portrait.jpg
Switch Snake Portrait.jpg (43.35 KiB) Viewed 311 times
Switch Snake Portrait disappear.jpg
Switch Snake Portrait disappear.jpg (139.75 KiB) Viewed 311 times
User avatar
Tony Li
Posts: 22163
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Character portraits in script

Post by Tony Li »

Hi,

Treat the dialogue database as read-only at runtime.

When a conversation starts, it caches the actors' info, including their display names and portraits. Try changing the cached value. Example:

Code: Select all

DialogueManager.conversationModel.SetActorPortraitSprite("Fruit Snek", snakeSegments[9].segment.sprite);
User avatar
rykaan
Posts: 75
Joined: Tue Feb 11, 2020 6:22 am

Re: Switching Character portraits in script

Post by rykaan »

Thanks Tony,

The portrait being removed on the following line of dialogue had something to do with using the sequence command. When I switched to using the code you suggested it switched correctly. By using both the cache change in conversation + the database change, the portrait is correct for subsequent conversations too.

Cheers!
Rob
User avatar
Tony Li
Posts: 22163
Joined: Thu Jul 18, 2013 1:27 pm

Re: Switching Character portraits in script

Post by Tony Li »

Hi Rob,

Great! Glad it's working now.
Post Reply