-
Notifications
You must be signed in to change notification settings - Fork 1
Network
-
ip = server address
-
port = server port
-
mode = protocol type (Tcp / Udp)
-
Network Installer
NetworkInstaller is the entry point for the entire network system.
You can easily Enable/Disable the network by putting the prefab with NetworkInstaller component In/Out of the
Resources/Installers
directory. -
Network Object
Every network object needs to add a NetworkIdentityComponent and must be created using NetworkPrefabFactory.Instantiate().
-
UserId is bound to the id of the server user table.
-
InstanceId when created by a, it will be automatically incremented in order to prevent duplicates.
-
-
Network Player
In addition to adding NetworkIdentityComponent, each network player also needs to add NetworkPlayerComponent.
-
Network System
All network systems must inherit from NetworkSystemBehaviour.
You can send a request to the server by calling method NetworkSystem.Publish() in a system that inherits NetworkSystemBehaviour (But note that the data type of the request sent must be byte[] or string).
Of course, you can also subscribe to the response returned from the server through method NetworkSystem.Receive() or the method NetworkSystem.Receive<byte[]>() (Can refer to LoginSystem).
-
Lockstep Method
You can use LockstepFactory.Create() to create a NetworkGroup in a system that inherits NetworkSystemBehaviour.
Then you can synchronize user inputs by subscribing to the OnUpdate field of the NetworkGroup instance (Can refer to InputSystem).
After that you need to create a INetworkTimeline through the CreateTimeline() method of the NetworkGroup instance.
Finally, by subscribing to the OnForward and OnReverse fields of the INetworkTimeline instance to apply user inputs, Forecast and Rollback user inputs when the network is unstable (Can refer to PlayerControlSystem).
Incidentally, the global settings of lockstep can be configured by LockstepSettings.