Collisions detection must be done on the server (else people can hack, ex: go through walls), however, I have node idea really on how to approach this and was wondering if anyone has tried to do something similar before.
I’m guessing I must load a mesh on the server ( a mesh that covers all the areas a player can walk on) , and then crosscheck current player position and see if he is allowed to be there and allow movement or not.
Can anyone give me any tips? Or had any similar challenge?
Yes, I saw that, and as stated on that post, there is no server validation of any kind, hence not really relevant to my question. (this said, maybe it could, but I faill to see it)
Thanks for that very detailled answer, it’ll take me a while to digest.
Sorry for my ignorance, but I was wondering if I needed to run a physics engine as I’m a bit worried it’ll bring too much complexity too quick as I’m still quite new at this stuff,
At this stage, I only need environment collisions. For all characters I could do a basic checks between players positions to check for collisions if need be.
To be honest, everyone I asked has suggested to use a physics engine on the server similar to what you are saying, however I think I need to try my own way with some sort of walkable navmesh and to unsure players stay withing those limits.
That’s part of the learning process, and I guess after failing miserably, I will have to dive into implementing a physics engine
Now I see what you mean in your original question. Yes that should also work. I think the steps in my last reply is still valid for this appoach. Instead of validating with a physics engine, on the server side, you need to calculate the positions of agents at the next clock tick based on their velocities (speeds and facing directions), and validate the new positions with navmesh on the server side. And then broadcast the new world state (positions of agents) to all the clients.
@slin thanks, glad I make sense, and that you think it can work that way too,
So based on what your said, I can use the NullEngine on the server side to create my scene, load the navmesh & make sure the players are in a contact with that navmesh.
That lead to another issue, I have multiple rooms/zones on the server, so I’ll have to run multiple scenes at the time, and make sure my collision logic is running on each scenes independently: Another level of complexity, great
I wouldn’t worry about it right now, because gameplay and controls will dictate which approach you take. I’d just structure it where your input commands do not directly set your scene state. This way, you can either have a local handler or a networked handler.
Also, i don’t think you need collision detection on server (for walls, maybe for players or something gameplay specific later, sure). You already have player positions on the server, so one approach could be to just start logging positions after they get reported and see if the movements are possible. Doesn’t really have to be in real time to keep cheaters out.
How would I know if a movement is possible or not, if I dont have the world/navmesh loaded on the server to crosscheck what is allowed or not? Maybe I missunderstood you?
My understanding from @jeremy-coleman is: cheating is treated like using bad language etc in a game session. After the game this player will be reported by others. With log on the server admin can verify the report and punish this player in a way designed in your game platform.
If you run collision detection and navmesh verification mostly by your own implementation, you might not need NullEngine. It is likely to have a larger memory footprint than necessary.
That lead to another issue, I have multiple rooms/zones on the server, so I’ll have to run multiple scenes at the time, and make sure my collision logic is running on each scenes independently: Another level of complexity, great
After your game became popular, you will also need to have multiple servers for hosting game sessions. Together with that you will need a service discovery service that registers all the available game servers. And you will start monitoring the load on these game servers to allocate players to the server with low workload…Finally the complexity will pay back and you start driving a Lamborghini.
I’ve got the first iteration of my networked collisions sorted out. It involves using unity to generate a navmesh, but technically you could use any software to do that.
It only works on the X and Z axis at the moment, meaning the world must be flat, but that doesnt bother me yet and I can be easily adapt that if need be.
So what I did is:
Create a navmesh with unity
Export it with a C# Script as an OBJ mesh (I used a script I found on internet somewhere the other day).
As you can see, characters still ends up into the wall a bit (that’s due to the ping & my client side prediction movement, and by the time the server has checked everything, player is already in the wall slightly), but can be resolved by doing the same collision check as the server but on the client . Anyway, even if the player does manage to cross the wall, the server will eventually reset the player position back to where he should be.
I still need to do some tweeking to but I’m very happy with the initial result.