This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CharacterController : MonoBehaviour | |
{ | |
private ClientInputState inputState; | |
private Vector3 velocity = Vector3.zero; | |
private int simulationFrame; | |
private void Start() | |
{ | |
NetworkClient.RegisterHandler<SimulationState>(OnServerSimulationStateReceived); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SimulationState : Message | |
{ | |
public Vector3 position; | |
public Vector3 velocity; | |
public int simulationFrame; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ClientInputState : Message | |
{ | |
public List<KeyCode> keysPressed; | |
public List<KeyCode> keysDown; | |
public List<KeyCode> keysReleased; | |
public int simulationFrame; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Psuedo implementation to send data to a client. | |
NetworkServer.SendToClient(NetworkConnection connection, Message message); | |
// Psuedo implementation to send data to the server. | |
NetworkClient.Send(Message message); | |
// Psuedo implementation to register incoming message handlers. | |
NetworkClient.RegisterHandler<T>(Action<NetworkConnection, T> handler); | |
NetworkServer.RegisterHandler<T>(Action<NetworkConnection, T> handler); |