Recently our company have started using NodeCanvas. Unfortunately today we’ve got a problem we cannot solve.
We are having an GameObject with BehaviourTree on it. After creating about 50 entities of that gameobject we’ve noticed a huge frame rate drop so we checked the unity profiler to see what’s wrong.
With about 50 gameobjects on the scene profiler shows 126680 Calls of MessageRouter.OnTriggerStay() method. So we’ve looked up at the MessageRouter.cs class and found out that it contains implementations of all unity callback methods (OnTriggerEnter, OnTriggerExit, OnTriggerStay, etc). It even contains implementations for 2D stuff, which we don’t need. (As we know even emtpy unity method declaration has performance impact). So each object that has MessageRouter class on itself is getting all off the unity callbacks what eventually is killing the performance of the game.
We are wondering if there is any way to avoid getting all of those callbacks.
Our idea is to clear all callbacks in MessageRouter class and in each object we create get a reference to MessageRouter class and call Dispatch from methods we actually use, but we would like to have your opinion on the subject, because our method will have a lot of impact for the NodeCanvas framework.
This is indeed something I am trying to work around differently (if possible), because in some situations (like yours for example) it can be a huge hit and unfortunately Unity does not has “proper” events for these callbacks.
Probably the solution I will be going after officially, would be to create a few separate MessageRouters, each related to a specific set of callbacks, like for example “MessageRouter_TriggerEvents”.
As a temporary solution to that until updated, and like you suggest doing, removing the callbacks in MessageRouter that you don’t need (all but except OnCustomEvent), won’t affect the framework, other that of course the action/condition tasks, that make use of these callbacks.
So naturally, removing OnTrigger_X callbacks from MessageRouter, will make the CheckTrigger condition task not work, but everything else will work fine. You can then get a reference to MessageRouter and call it’s methods from any code your like, yes.
Let me know if that worked for you, or if your encounter any issues in doing so.
Thank you!
Thank you for your response. For now we just removed unnecessary callbacks out of MessageRouter class and it works definitely faster.
As a solution we are going to use the reference to MessageRouter and call it’s method wherever it’s needed. If there will be any problems with that I’ll let you know.
However I have one more question not really related to previous one. As we can see Node Canvas supports AOT (AOTDummy). So can we use it with ill2cpp (like on iOS or Playstation) without problems?
Thanks for the follow up.
Yes, NodeCanvas supports AOT and should be able to be used with il2cpp without problems. You will just need to generate the AOTClasses.cs file through the Preferred Types Editor as explained in this [LINK].
Thanks.
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.