Unity Fighting Game with 2 players
Posted: 17 Feb 2017, 14:50
Hi there,
So I read a lot of documentation and go through the tutorials. I'm working on a fighting 2D game (like Street Fighter) with 2 players only made with Unity. Unfortunately I didn't find enough informations about this, the topics on the forum were very brief.
I'm using SmartFoxServer for Room creation (2 players max) and then the fighting part though it could be done via P2P or Socket (but I don't want to bother with Firewall issue etc.).
I want to benefit from Unity engine and its physics, so the Room creator will be the Master and the other one the Slave. Since there are only 2 players, I don't need to run the physics on the server, right? It will save me lot of time because it will be easier with Unity.
This is my current process:
- the Master client run physics on its side, and send users positions to the Server.
- the Server dispatches this information to the other player.
- the Slave receives both user positions and make an interpolation.
- the Slave sends its input to the server.
- the Server dispatches the input to the Master.
- The Master applies input on the remote player and so moves its physics. Then the current process starts again.
Obviously I sent only informations when something is changing, so if a player doesn't move there isn't any message sent to the Server.
As you can imagine, I suffer from lag... What I think to do next :
- use UDP.
- use RoomExtension instead of ZoneExtension, does it will change anything concerning performances?
- I send messages in a Unity's update method (so 60 fps), move to a 10 fps max method.
- put physics too on Slave side so it can also move on its side directly after the input and then interpolate from the Master's result.
What do you think? Am I missing something? With my architecture, the slave must send informations to server then master then go back to server then slave, is it a big mistake or not? If it's, I will have to change all my fighting game logic on the server and it will take way more time to program.
Thanks for your help,
Aymeric
So I read a lot of documentation and go through the tutorials. I'm working on a fighting 2D game (like Street Fighter) with 2 players only made with Unity. Unfortunately I didn't find enough informations about this, the topics on the forum were very brief.
I'm using SmartFoxServer for Room creation (2 players max) and then the fighting part though it could be done via P2P or Socket (but I don't want to bother with Firewall issue etc.).
I want to benefit from Unity engine and its physics, so the Room creator will be the Master and the other one the Slave. Since there are only 2 players, I don't need to run the physics on the server, right? It will save me lot of time because it will be easier with Unity.
This is my current process:
- the Master client run physics on its side, and send users positions to the Server.
- the Server dispatches this information to the other player.
- the Slave receives both user positions and make an interpolation.
- the Slave sends its input to the server.
- the Server dispatches the input to the Master.
- The Master applies input on the remote player and so moves its physics. Then the current process starts again.
Obviously I sent only informations when something is changing, so if a player doesn't move there isn't any message sent to the Server.
As you can imagine, I suffer from lag... What I think to do next :
- use UDP.
- use RoomExtension instead of ZoneExtension, does it will change anything concerning performances?
- I send messages in a Unity's update method (so 60 fps), move to a 10 fps max method.
- put physics too on Slave side so it can also move on its side directly after the input and then interpolate from the Master's result.
What do you think? Am I missing something? With my architecture, the slave must send informations to server then master then go back to server then slave, is it a big mistake or not? If it's, I will have to change all my fighting game logic on the server and it will take way more time to program.
Thanks for your help,
Aymeric