Hello everyone!
Background:
I've been working on a fighting game project for a few years now, but due to switching engines I've faced the challenge of migrating / restarting.
I've written a Client - Server logic where client executes (predicts) and sends “new player” and “controller status” messages to the server. The server processes the messages and broadcasts the results ("add user" and “final positions”). When clients receives the messages from the server they set other's values or check if the predictions were right, and otherwise reconciliate.
All that was relatively fine.
Now:
When reimplementing, I decided to create a character selection screen before jumping into gameplay. There's where I found that if I want to really do it the “client-server” way, I should be sending the “controller status”, and the server should be broadcasting each cursor position, status, character selection, screen item enable/disable, etc. etc. Otherwise, I would here (it's just a character selection screen after all) just cheat and the server would forward the “controller status” so the clients process it like if it were locally.
Still some questions came to me:
1) Should the server always broadcast the full scene status? (characters' positions, orientation, health, actions, powers acquired / ready to use, etc.) I have seen tutorials where they broadcast only upon “controller status” reception, but when having NPCs, time / logic triggers, then you should as well broadcast. So is it worth it to be selective for all these cases, or just broadcast always?
2) Defining messages types to send back and forth info ends up being really bad for design and flexibility. I feel like I'm totally constrained and one would end up whether using one message for all (repurposing the fields) of defining a million different message types ("cursor redraw", “character redraw”, “whatever event", “player won”, “player changed armor”, “player changed weapon”, etc.) Any advice here?
3) Server can broadcast final positions for the client to put the characters where the server says. I thought of including the “action” as well (attack, jump, etc.) But when the client receives the “action”, the client has to process it (needs to play the animation, show particles, effects, sounds, etc.) Is this a correct approach? Should I also consider anything else vital that I'm not seeing at the moment?
THANKS A LOT!