0
\$\begingroup\$

I recently started coding a game with one of my friends and he is taking care of the front end and I am doing the back end.

I read many blogs/articles/tutorials on how the back end communicates with the client side and they all show different ways of doing this.

In our game the player can move his character by right clicking where they want to go. Does this mean the movement happens on the client side or should the client send a coordinate to the server and the server checks if its valid and responds with 'move_verified' which then allows the client side to carry out the action?

If this is the case how does collision take place because it will have many calculations and can cause major stress on the server. but doing it client side will make it vulnerable to malicious scripts.

The game needs to be in real time and 10 people will be playing simultaneously in a single match.I know the coords of all players have to be constantly sent to the client from the server so each player can see all players.

We are using Unity and socket.io. We successfully got communication with one another. But I just want to make sure I am on the right track before I start going deeper into the code.

I can show my code if its needed but its bare bones connections.

Thanks in advance!

\$\endgroup\$
4
  • \$\begingroup\$ 10 players' worth of collisions doesn't sound like an unusually high load for the server to handle. Have you observed any problems when doing it this way? \$\endgroup\$
    – DMGregory
    Oct 24, 2018 at 5:35
  • \$\begingroup\$ the collision isn't too bad if its just one game. But I'm worried that multiple rooms can be going on at the same time with 10 people in each. Or would that not really effect it? \$\endgroup\$
    – schylake
    Oct 24, 2018 at 5:39
  • \$\begingroup\$ There's one way to find out for sure: build a test and profile it on your target hardware. \$\endgroup\$
    – DMGregory
    Oct 24, 2018 at 5:49
  • \$\begingroup\$ That is true, So do I have the right idea with how I'm looking at server communications? \$\endgroup\$
    – schylake
    Oct 24, 2018 at 5:53

1 Answer 1

1
\$\begingroup\$

In our game the player can move his character by right clicking where they want to go. Does this mean the movement happens on the client side or should the client send a coordinate to the server and the server checks if its valid and responds with 'move_verified' which then allows the client side to carry out the action?

Yes, this is what you should be doing. However, in order to improve the user experience, you might still execute the move on the client-side immediately and not wait for the server confirmation. Otherwise the game will appear laggy.

If this is the case how does collision take place because it will have many calculations and can cause major stress on the server.

But will it cause major stress on the server? Have you tested it? I don't know how complex collision detection is in your game, but chance is you are overestimating the required effort.

There are also a lot of techniques you can use to optimize collision detection. For example, you can use axis-alligned bounding boxes to pre-select potentially colliding objects with more complex colliders or you can use spatial hashes and only check for collisions in adjacent chunks. This is a very wide topic, so if you actually notice any performance problems with your implementation, feel free to post further questions.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .