-
-
Notifications
You must be signed in to change notification settings - Fork 305
Unity Integration Network Start
Since Unity does not work as fast as Forge Networking, there are a few control flow features that we've added into the Unity Integration to allow you to plan your network setup for network objects. When you implement your generated Behavior script that was generated from the NCW, you can override a function named NetworkStart
.
NetworkStart
is automatically called, when the object has been setup on the network and is ready to do things like send RPCs, update fields, etc.
Below is an example of how to override the NetworkStart
method in order to disable a camera on a game object that is not owned by the current instance and set our fields update interval.
using BeardedManStudios.Forge.Networking.Generated;
using UnityEngine;
public class NetCam : NetworkCameraBehavior
{
protected override void NetworkStart()
{
base.NetworkStart();
Camera cameraRef = GetComponent<Camera>();
networkObject.UpdateInterval = 100;
// If this is not our camera then we should not render using it
if (!networkObject.IsOwner)
cameraRef.enabled = false;
}
}
For your convenience, we've added a networkStarted event to NetworkBehavior
so that you can do other operations on other objects that have a reference to the object in question.
For example; if you instantiate the object (obviously from another script) and you want to do some special action on that object once it has been setup on the network, you can hook into this event.
var cameraPlayer = NetworkManager.Instance.InstantiateNetworkCamera();
cameraPlayer.networkStarted += CameraReadyOnNetwork;
// ...
private void CameraReadyOnNetwork(NetworkBehavior playerCamera)
{
UnityEngine.Debug.Log("The player camera " + playerCamera.name + " has been setup on the network");
}
Getting Started
Network Contract Wizard (NCW)
Remote Procedure Calls (RPCs)
Unity Integration
Basic Network Samples
Scene Navigation
Master Server
Netcoding Design Patterns
Troubleshooting
Miscellaneous
-
Connection Cycle Events
-
Rewinding
-
Network Logging
-
Working with Multiple Sockets
-
Modify Master and Standalone servers
-
NAT Hole Punching
-
UDP LAN Discovery
-
Offline Mode
-
Ping Pong
-
Lobby System
-
Upgrading Forge Remastered to Develop branch or different version
-
Forge Networking Classic to Remastered Migration Guide
-
Script to easily use Forge Networking from sources
-
Run Two Unity Instances with Shared Assets for Easiest Dedicated Client Workflow