Hi,
So, for my project I added some optimization for NPC (monsters and enemies). When entity is outside of visible area (what is checked by VisibilityEnabler
) I do only simple movement and avoid all unncessary calculations (like animations blending etc.) and also animations are paused (using default feature of VisibilityEnabler
). I did that because I already faced frame rate drops when there were many enemies spawned, but only few visible. That optimization seems to work fine and I am happy with that, but there is one issue with animations pausing.
In animations I use function call tracks sometimes (for attacks, special skills etc.) and in that case when animation is paused it means for example that enemy will never trigger hit check. I knew that when I added that optimization, but I thought it will be rare case anyway (fighting off screen). However now I implemented special skills and that optimization cause issues in below scenario:
1. Monster start using skill
2. Particles are spawned
3. Player rotate camera, so monster is getting invisible
4. Skill ends (because skill time is based on timer), but spawned particles stay, because their destroy supposed to be called from animation at proper time
I can't pause everything when enemy is off screen, because then player can just avoid looking at the enemy to avoid fighting and have as many time as he want to prepare. I could just not pause animations, but does it make sens to play animations for enemies not visible on the screen anyway (does Godot have some optimization for that internally and I shouldn't care about that too much?).
For me the best solution would be to pause all "visual" animation part (for example to avoid complex skeletal mesh deformations), but still keep playing function call tracks. Is that possible?
I could of course "recreate" all that function call points from animations as some defined const times and use timer instead of animation track, but ughhh, that would be much additional work and using animation tracks seems to be a lot cleaner approach (than defining times in some dictionary mapping animation -> trigger time).
I am curious if anyone had already similar issue or you have some advices.