I have learnt about “Object-Pooling” which great for performance and i want to use it when npc system. I want to handle when npc died instead of destroy the old npc and replace with the new one to setting it’s health back to maxhealth. but turn out this doesn’t working. so is there a way or no way for this?
object pooling is meant for case where you often clone and destroy simple objects (projectiles, particles)
since you are using humanoid NPC’s, you are more likely using small amount of them, so you wont get really any improvement from object pooling
2 Likes
HafuPlay is right. Unless you are spawning hundreds of NPCs every second, the overhead of Humanoids makes pooling mostly pointless. Just use a simple respawn script that resets the state instead of worrying about complex pooling logic.
1 Like