📄Documentation

Sample workflows and important notes to assist your experience with MADNET

Writing Networked Scripts:

Create a new C# script in Unity and inherit NetworkBehavior

Flow logic:

Movement code should be client-authoritative, while certain codes, such as validation of a task's completion, are best done on the server. Client and server communication is established with NetworkInvoke()

To invoke a function on all connected clients, call NetworkInvoke("FUNCTION_NAME", object[] parameters, bool includeOwner)

If includeOwner = true, the function will be invoked again on the calling client

NetworkIdentity.isLocalPlayer returns true for the current local client that has authority, useful for player control scripts where only the object with authority should respond

Adding Movement:

Attach NetworkTransform to any GameObject you wish to sync transform with.

Sync Options:

  • Position

  • Rotation

  • Scale

NetworkTransform can be adjusted based on the type of game you are making. For slower pace games, increase the Sync Interval; for faster pace games, ie. FPS Shooter, decrease the Sync Interval for more accuracy. Lower Sync Interval increases network usage.

Spawning GameObjects:

Register a prefab by adding it to NetworkManager's registeredPrefabs. You can get a GameObject's registered NetId using GetRegisteredSpawnPrefabID(GameObject gameObject)

Last updated