easy-games / chickynoid

A server-authoritative networking character controller for Roblox.
https://easy-games.github.io/chickynoid/
MIT License
221 stars 31 forks source link

fix CreateModel character spawn delay & memory leak #25

Open royal0959 opened 1 year ago

royal0959 commented 1 year ago

modelPool did not function as a player's model pool is removed each time DestroyModel is ran. this made the function reapply the same humanoid description each respawn, delaying respawning client-side for up to a second due to GetHumanoidDescriptionFromUserId & ApplyDescription - this delay is especially notable when a player's visiblity callback (CanPlayerSee) changes, in which case it will cause a very noticeable delay when the player model needs to be spawned in again

additionally, while modelPool is removed its model parented in lighting is never destroyed and a new model would continue to be created on each client each time a player respawns and are never cleared until the client rejoins

I had made it so the cached model updates its humanoid description after each respawn to still sync with player's roblox avatar, although it now takes 2 respawns to load in a new avatar rather than 1 respawn