How to clone multiple instance of director/collision manager


Hi im building a nodejs server with cocos engine. I need to make about 500 rooms of game, each have a same size area with many node in that.

Since cocos engine is built in modules, so i cant create different game instance (cc, ) variable to manage each room. So i have to put all 500 node-game into a parent node, and each have its own child which is game character, monster, missile v.v… It’s acceptable but the problem occurs if i use collision manager to check collide. Because there is only 1 collision manager to manage node, there is many cross-check which is useless, even i put a parent-check for each game area.

How can i use multiple instance of cocos to solve my problem?


Im not sure i understand the exact problem.

But to fix the collision problem try a optimisation pattern called spatial partitioning.
What it basically does is puts your nodes into grids and only checks collisions if the nodes are in the same cell. basically removing all the cross checks etc.


Thank you, i fix that problem by creating different collision manager :slight_smile:

var cm1 = new cc.CollisionManager();
var cm2 = new cc.CollisionManager();
cc.director.getScheduler().scheduleUpdate(cm1, cc.Scheduler.PRIORITY_SYSTEM, false);
cc.director.getScheduler().scheduleUpdate(cm2, cc.Scheduler.PRIORITY_SYSTEM, false);
cm1.enabled = true;
cm2.enabled = true;