How to prevent cheating?

If you’d like to run PlayCanvas directly on a Node.js backend you might find this post helpful. I haven’t tried it myself yet, but I’ve heard some people have some success using jsdom to run PlayCanvas in a simulated document.

Not to sidetrack too much, but I’m also kind of curious as to what the best approach might be for running a backend with PlayCanvas as the frontend. With the engines I’ve used (namely UE4, Source Engine and Unity with UNET & Mirror), it’s always been very helpful to have the client and server code incorporated into the same codebase running on the same engine. This allows for running listen servers, i.e. a local server that runs on a client and can be connected to by local or remote peers. This is particularly helpful when you want to host LAN games, create P2P games without the need for hosting fees other than a matchmaking backend (although P2P does usually mean more latency, looking at you CoD with host advantage) or have a single player game that still uses the same networked code as the multiplayer portion of the same game.

Using a separate codebase on the server without the main engine would mean a few things could become quite difficult:

  • When you want to spawn an entity over the network from a template (maybe a player pawn), you’d have to implement the same template instantiation mechanism on the server and ensure all templates have settings identical to the settings on the clients so the clients can predict movements and behavior properly to mimic what’s happening on the server;
  • As previously mentioned, if you want an authoritative server that verifies player physics, you’d have to implement the physics engine yourself which is quite a nut to crack. This would also mean you’d have to implement an entity system with transforms, hierarchies, some form of the rigid body component, a scripting system that uses the same character controller scripts as the ones on the clients to replicate the exact movements on the server using the input from the clients, and likely you’d need other general engine features that are already available in PlayCanvas;
  • If you want to run a non-JavaScript codebase, there would be overhead in porting the same code to another language and you might have to deal with language specific issues (JavaScript is kind of picky for instance when it comes to mixing signed and unsigned integers in bitwise operations when serializing to a network stream);

I’d really love to have a catch-all solution for running listen servers on the client and dedicated servers without PlayCanvas on the backend, but so far I haven’t really been able to find the perfect solution yet. Perhaps I should make a separate threat before I hijack the discussion, sorry in advance haha. I absolutely agree it makes much more sense to run a more lightweight implementation on the backend to save on CPU & RAM (especially when scaling up with lots of concurrent users), but having to reimplement so much engine logic to get the same behavior between clients & the server is a daunting task. Hopefully this helps with the discussion a bit even if I went a tad off-topic perhaps :laughing:.

Edit: sweet lord I just realized this thread was created in 2018 and revived, haha oops

1 Like