- Home /
clean non relevant objects
hello guys!
I have a question regarding cleaning objects:
I'm working on a networked game where the server send each client states of objects that are nearby that player on each tick, which the client interpolates and visualizes said objects. I want to clean (hide or dispose) objects that are not updated for X time.
I thought of 2 solutions to achieve this cleaning problem:
1.creating a "cleaning" task that handles 2 inner tasks the first inner task will wait for a timeout and then clean (Hide/Dispose), and the 2nd task will intercept "Set" calls which will restart the wrapping task - The "set" will be called if an object had been updated in a tick and has an existing "cleaning" task running.
2. store a dictionary of object's ids and their ticks-before-clean-delta, and every tick go over this dictionary and clean (I think this solution is far worse due to it being O(N)^2 - OnTick * N loop).
Is there a better approach than that to clean non-relevant objects?
Thanks for any help!