|
Post by christougher on Sept 20, 2017 4:37:16 GMT
Hi, I'm noticing a significant fps drop when my enemies are initially spawned. The CPU footprint is much less on subsequent spawns. I know there are multiple factors in this, many of which have nothing to do with CGK, such as my AI... What is the best way to decrease this? I was thinking perhaps having a scene with only the levelwaveSettings prefab in it and spawn everything a couple of frames then deactivate them before additively loading the main scene. Any pointers or ideas? I'm kinda delving into unfamiliar territory...
|
|
|
Post by DarkTonic Dev on Sept 20, 2017 5:42:30 GMT
Could be a pre-warming problem. Master Audio calls a couple of its methods during initialization so that the code is pre-warmed and won't be slow on first call.
Or it could be that the scripts on your prefab are numerous and/or heavy on performance and are calling their Awake / Start methods only the first time they are spawned (which is actually normal). You will probably need to run the profiler and see if that gives more insight and report back.
|
|
|
Post by christougher on Mar 10, 2018 4:41:37 GMT
Finally got back around to troubleshooting this... so the culprit is Opsive's Behavior Designer needing to deserialize the behavior trees... I believe the only code I need to get this to happen when the level is loaded instead of when each one is spawned is this:
public BehaviorTree behaviorTree; ... behaviorTree = gameObject.GetComponent<BehaviorTree>(); behaviorTree.EnableBehavior(); behaviorTree.DisableBehavior();
I tried a custom script with this code in the Awake function but that doesn't get called till spawn time either... Where should I insert this code to run this when each pool item is instantiated but before it's disabled? Thx!
|
|
|
Post by DarkTonic Dev on Mar 10, 2018 5:36:38 GMT
That would be OnSpawned method, as the documentation for Pool Boss states. I think you should give it a quick read as it's not very long. Click the green question mark icon in the Pool Boss Inspector.
|
|
|
Post by christougher on Mar 14, 2018 22:28:09 GMT
So this was a wee bit more complicated. Does cgk need to be in the plugins folder? I couldn't reference Behaviour Designer in PoolBoss from within the plugins folder. Took me forever to realize the plugins folder restriction lol. I ended up changing poolboss to have SetActive to true when it instantiates the pooled items and then overrode the Killable with the custom script saved outside the plugins folder to set to false in its own awake method after initializing the behavior trees. I finally got the performance increase, no more frame drop EVERY time something was first spawned. Yay! I am getting some errors about referencing Pool Boss before it's ready tho.
|
|
|
Post by DarkTonic Dev on Mar 15, 2018 0:20:58 GMT
All code plugins you buy from the Asset Store should be in Plugins so that code does not need to recompile unless you change code in Plugins. You should keep your own code outside Plugins so you get faster compile times. Unfortunately almost all plugin authors don't follow this guideline but we do. We use Behavior Designer too, so we move it into Plugins as well so they can integrate.
You could also move CGK out into Assets and it may work but we don't know and don't support it.
|
|
|
Post by christougher on Mar 15, 2018 4:05:49 GMT
Thanks for the help! I'll have to see about migrating a fair amount of other assets into Plugins as I'm sick of the compiling pauses. It will be soooo much cleaner to reference BD directly within PoolBoss. Thanks again! Love your plugins. CGK and Master Audio are amazing. Incidentally I was recently trying to set up a looping monk chant effect and had another guy explaining all the complicated stuff I should do to get it working... aaaand I just used Master Audio instead and was up and running in no time with perfect fading in/out, seamless looping and effects.
EDIT... BTW long overdue however I've posted fitting 5 star reviews on the UAS for your plugins.
|
|
|
Post by DarkTonic Dev on Mar 15, 2018 4:26:28 GMT
Thank you very much for the reviews! Not all plugins support moving to Plugin folder (might have hard-coded file paths or other things - you would need to do some testing if you move them or ask the author). Also, you have to move the Editor scripts, if any, into Assets/Plugins/Editor which is not a child of where they normally are. So be careful if you want to move any others. It's generally just a 2 step process.
1) Move the Editor scripts into Assets/Plugins/Editor. I would make a {PluginName} folder there and drag them in. 2) Move the other non-editor scripts into Assets/Plugins/{PluginName} folder.
Then check things.
Great story about how you just got the chant working in no time flat!
|
|