[Help] Annoyingly Persistent Peds
I've started modding GTA with C# recently, and as a first test, I made a mod that spawns a ton of peds. It's all cool but when I kill them off, they never despawn, even if I leave the area for a day and come back. Anyone know a fix for this? Also, I've made a global ped variable and I'm not really sure what different handle values do.
You'll want to release the entity (
Entity) for the game engine to clean up, after spawning it.
npc.MarkAsNoLongerNeeded()should do the trick.
A decent strategy to manage disposable but scripted peds is to keep a list of them, check if they're alive once in a while, and if they're dead, mark them for the game to clean up, and then remove them from your list of managed peds.
@ikt Thanks so much!