We’re making an RTS based on the lockstep model. Movement was 100% accurate across the network until we added collisions using kinematic rigidbodies with is trigger compound colliders, now we lose sync. The Unity docs state that:
Is Kinematic: If enabled, the object will not be driven by the physics engine, and can only be manipulated by its Transform.
Does the Is Kinematic setting actually disable the physics engine, rendering the colliders usable for deterministic simulation?
If kinematic colliders are useless in this case, are there any suggestions on the best way to detect and deal with collisions in lockstep?
If you need deterministic collision detection this is something you will have to implement yourself, by hand - you can in now way use unitys PhysX engine for this. So yes the default Unity rigidbodies are next to useless for this.
That’s…frustrating. All we want is the collision data from the triggers, but as I mentioned, the data doesn’t seem to be guaranteed to be the same on two networked computers given the same starting conditions once collisions start in earnest. I keep crossing my fingers in the hopes that someone will tell me that I forgot to click an obscure checkbox on the colliders and everything will work. But failing that…
We’ve implemented a sort and sweep test, and so far it’s quite a bit slower. Which isn’t surprising, because it’s not running on the GPU. Other people must have had this problem as well. What do other lockstep (Unity) RTS games use for collision detection? So far I’ve looked into a few options: sort and sweep, quadtree, trying to integrate Bullet Physics…
I have found that using a simple quad tree is very well suited for a lot of game types, despite it’s inherent 2D nature. As unless you’re in space or doing a flight-sime you are most likely going to move mostly on the X/Z plane and very seldom on the Y axis. If you base your positions on integers (which you should anyway, since you need deterministic behaviour) you can get a very very fast quad tree.