fredi-68 / luswca

Remember to put full project title here
GNU General Public License v3.0
0 stars 0 forks source link

Server Physics #51

Open fredi-68 opened 5 years ago

fredi-68 commented 5 years ago

A server side physics engine is required for multiple things like pet and enemy behavior but also event and mission triggers like the switches in the AG monument or certain cutscenes. To have these events fire on the server we need to keep track of the position of all players in the game as well as all objects that have physics or act as a collider. More research is required on which objects need to have collision. ReplicaObject and Component could interface with the physics engine through methods defined on the ReplicaObject itself, like getClosest() faceTowards() etc., as well as event handlers like onCollision(), onTriggerEnter() or onTriggerLeave(). These would be easy to implement, the bigger challenge is creating the physics engine itself. Since I have literally zero experience in dealing with 3D physics I will have to do some research on this topic before I can really get started.

fredi-68 commented 4 years ago

Got a rudimentary physics engine working, still need to add collision/proximity detection. Since this is already slowing down the server quite a lot with just one player on it, I want to outsource this to a C++ module if possible.

fredi-68 commented 4 years ago

We may be able to skip on doing collision detection completely. AI pathing (enemies and pets) can be done using navmeshes, and other than that the only thing we really need is proximity detection (for now). The number of objects actually requiring proper box collision are quite limited. For proximity detection, we can track a list of objects that have moved recently and check them ever tick, which is a lot more efficient than what we are currently doing.

fredi-68 commented 4 years ago

additionally, we could define proximity detection using event callbacks instead, only using it when the object has requested this feature. This would further lower server load by ignoring objects which do not depend on proximity detection at all.