Bark On Idle profiling

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
mandi
Posts: 77
Joined: Wed Sep 16, 2015 4:05 am

Bark On Idle profiling

Post by mandi »

Hello Tony,
I've noticed some serious peaks in profiler considering Bark On Idle, sending you a screenshot.
Best!
Attachments
BarkOnIdleProfiling.jpg
BarkOnIdleProfiling.jpg (105.98 KiB) Viewed 712 times
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bark On Idle profiling

Post by Tony Li »

Hi Artur,

Yes, starting a bark can involve a lot of work. The "quick fix" if you don't use conditions is to tick Cache Bark Lines.

The most expensive operations are usually:
  • Evaluating Conditions on dialogue entry nodes that link from START.
  • Running sequences.
  • Any OnBarkStart methods in your scripts that do heavy processing.
If you need to use conditions, you can optimize the process by grouping barks into separate conversations, using a separate Bark On Idle with a Condition for each conversation, and ticking Cache Bark Lines on them.

For example, say you have a character "George" that barks some lines when he's hurt ("I'm bleeding!", "Am I gonna die?", etc.) and other lines when he's healthy ("Hi!", "Nice day, eh?"). Say you have also registered a Lua function "IsHurt(characterName)" that returns true if the character is hurt.
  • Create two conversations, for example titled "Hurt Barks" and "Healthy Barks". Don't put any Conditions on the dialogue entry nodes. (Or at least minimize the number of Conditions if possible.)
  • Add a Bark On Idle component to the character.
    • Assign the "Hurt Barks" conversation.
    • Tick Cache Bark Lines.
    • Open the Condition foldout, and add a Lua condition: IsHurt("George")
  • Add another Bark On Idle component to the character.
    • Assign the "Healthy Barks" conversation.
    • Tick Cache Bark Lines.
    • Open the Condition foldout, and add a Lua condition: IsHurt("George")==false
There are other ways to optimize barks, too, depending on your needs. You can set link priorities. The Dialogue System will evaluate only the links at the highest priority first. If it finds a valid entry, it will stop evaluating the rest of them.

If you temporarily set the profiler to Deep Profile, you can get more details about what's taking the most time. It's probably Lua conditions, but it could be something else such as spinning up the sequencer or setting up the bark UI if it uses a lot of Unity UI auto-layout features.
mandi
Posts: 77
Joined: Wed Sep 16, 2015 4:05 am

Re: Bark On Idle profiling

Post by mandi »

Tony,
thank you very much!
Best!
User avatar
Tony Li
Posts: 22107
Joined: Thu Jul 18, 2013 1:27 pm

Re: Bark On Idle profiling

Post by Tony Li »

Happy to help!
Post Reply