Object Pooling for Entity Schemas in MapSchema Causes 'refId not found' Error" #821
haipc01224
started this conversation in
General
Replies: 1 comment
-
I recently implemented this and have found that you need to reset However, unless you can guarantee that every single synchronized property will be overwritten with a new and different value, you must set all property to If the old and new uses of the item happen to use the same value, it will not update the change tree. This means that that property is not synchronized and you get seemingly-random Example: export class PointState extends Schema {
@type("float32") x: number;
@type("float32") y: number;
constructor(x: number, y: number) {
super();
this.x = x;
this.y = y;
}
/** Reset `$changes.refId` and all properties to `undefined` */
wipe() {
this["$changes"].refId = undefined as any;
this.x = undefined as any;
this.y = undefined as any;
return this;
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My game currently adds and removes a large number of entity schemas using a mapSchema to manage entities, which causes heavy GC activity that monopolizes the main thread. I tried to implement an object pool for entities but haven't been successful. At the moment, I don't know how to reset or clear an entity so that it can be returned to the pool. If I keep the data unchanged, the client throws a 'refId not found' error.
Beta Was this translation helpful? Give feedback.
All reactions