Huge performance hit when instantiating an agent's behaviour

NodeCanvas Forums Support Huge performance hit when instantiating an agent's behaviour

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #9563

    Hi, We’re developing a third person shooter for mobile platforms. There are maximum number of 3 agents existing on any scene.Agents are loaded into memory during loading screen and the object pooling system we have handles swapping the dead ones with newly created ones. The problem is when we enable BehaviourTreeOwner of an existing agent, we experience a huge performance hit. What can we do to fix this?

    #9565
    Gavalakis
    Keymaster

    Hello and sorry for the late reply.

    The first time a BehaviourTreeOwner is enabled or in it’s Awake (whichever is called first), the assigned BehaviourTree is getting initialized, which basicaly is deserializing from JSON. This is something that is somewhat costly and the reason you might experience this.
    Are the pooled agents loaded during the loading screen have the chance to get their Awake called? If so there should be no performance hit when you enable their behaviour later on.
    Are you maybe instantiating the agents disabled?

    Let me know.
    Cheers!

    Join us on Discord: https://discord.gg/97q2Rjh

    #9564

    The culprit was ingame switching behaviours. Initially we had an idleBehaviour and a combatBehaviour to keep things separated. We tried to initialize both of the behaviours behind the loading screen but it failed. Burying the idle behaviour into combat behaviour fixed the issue.

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.