- Home /
Dealing with rigidbody collisions when sending player positions across network
I'm creating my first networked game in unity. It's a simple 2D version of "Tag." I've got the game running fine on two machines connected to each other.
I'm using two methods for sending messages between the machines.
1) Input-based messaging (sending key codes).
2) State-based messaging (sending positions)
I can swap between both methods.
When receiving input-based messages, the client adds a force in the direction of the input to the remote player's game object, as follows:
By applying force to the object, collisions are handled automatically by the rigid bodies. This results in accurate collisions for both machines.
When receiving position-based messages, there is no force and thus no "proper" collisions. When players are moving fast enough, they simply pass through each other. It's not possible to have both machines sending both player's positions across the network. This will cause conflicts.
So I guess the question is, can I handle such collisions without an authoritative server and without sending direction/force vector data across the network (i.e with simple positions)?