How to handle collisions server-side?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Feelzor


I am using Godot server as explained in the tutorial, but I’m struggling with collision checks. I have multiple players that move in the scene and multiple projectiles. As I don’t want to trust clients for cheat prevention reasons, I’m trying to handle collisions server-side.

The problem is I don’t want to instanciate the whole scene server-side. It seems very resource-consuming. I have the same problem with player movement. How am I supposed to check for collision and/or correct movement speed without duplicating the code from client to server?

Thanks for your answers.

I have never really used server in Godot b4,but I’ve read tutorials for future uses…
For me,I would instance the scene both sides…cause the server needs the data to detect the collision.
After that,I would guess that u just need to do exactly how u did without the server,but just add a line which checks whether the current network is a server.
At least this is how my first try would be…
However,I’m not sure whether it will affect anything else unless I try it myself…
I’m still a beginner too…lol…hope it helps a bit…

God Of Theory | 2020-05-08 00:46

:bust_in_silhouette: Reply From: blockchan

You can’t really. Run server without renderer, so the only thing computed is physics and engine code.