Page 1 of 1

Bark On Idle profiling

Posted: Fri Apr 22, 2016 4:53 am
by mandi
Hello Tony,
I've noticed some serious peaks in profiler considering Bark On Idle, sending you a screenshot.
Best!

Re: Bark On Idle profiling

Posted: Fri Apr 22, 2016 9:57 am
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.

Re: Bark On Idle profiling

Posted: Fri Apr 22, 2016 12:35 pm
by mandi
Tony,
thank you very much!
Best!

Re: Bark On Idle profiling

Posted: Fri Apr 22, 2016 1:19 pm
by Tony Li
Happy to help!