Hi, I create a game with about 10 npc that go back and forth to infinity with tasks and the problem is small drops in fps when I move on the map (from 150-200 to 40-50 and when I stop moving it goes back to minimum 150). there would be a way to avoid this? like avoiding moving the npc if it’s too far away from us or simply optimizing the tasks, i tried the multithread them but it doesn’t change that much if anything.
I can show you some code if you ask for it
To check: Are you sure that it’s the NPCs that are causing the problem?
In particular, have you done any performance diagnostics, such as via PStats?
yea i deleted them to see how much fps i have and it was 150 fps when i move and 200 if i don’t move so they are the cause
with PStats i have something like this
so i don’t know what represent the * which takes the most of ressources
Okay, fair.
So, in PStats, what happens when you double-click on the " * " collector, either in the list on the left or in the graph itself? You should see a new list appear, showing the sub-components of " * ", which may provide further clues.
ok i found the problem it was just an animation that was making the whole game slow down, do you know how we could optimize it or i just have to delete it from the game ? (it’s not an important animation that i can remove easily)
in any case thank you
Ah, I thought that might be the case: Panda’s default animation is done on the CPU, which can be a little expensive, I fear.
So, there are three options that I’m aware of:
First, you could reduce the number of vertices in the models–fewer vertices to be transformed means less work for the CPU.
Second, if you have models that are shared between multiple objects, and you don’t mind them animating in lock-step, then you could use Panda’s node-instancing trick. This would allow Panda to essentially animate just one set of vertices per common model, rather than one set of vertices for each individual object.
See here for more:
https://docs.panda3d.org/1.10/python/programming/scene-graph/instancing
And third and final, you could use hardware animation. (a.k.a. “Hardware skinning”, I believe.) This would result in the work being done on the GPU instead of the CPU, thus freeing up the latter.
However, I don’t think that Panda provides this feature out-of-the-box–implementing it might involve writing your own shaders. That said, you could perhaps search the forums and see whether anyone has posted a snippet demonstrating the technique.
Ok thank you a lot