Wobbly Life Mod SDK
 
Loading...
Searching...
No Matches
Creating a Network Object

In order to do any sort of communication over the network in Wobbly Life you will need to create a Network Object. What is a Network Object? A network object is an object which has a unique id which is synced with all the players in the game. This allows you to easily send/recieve data to that object.

To create a Network Object in Unity you will need to use the script ModNetworkBehaviour.cs, this script should be derived from for custom implementation.

For this example we are going to create a new script called MyTestNetworkBehaviour

We have then derived from ModNetworkBehaviour like so.

There is 3 functions you should override (Note: They are also called in this order)

protected override void ModRegisterRPCs(ModNetworkObject modNetworkObject)
{
base.ModRegisterRPCs(modNetworkObject);
}

This is called when you should register any rpcs. We will talk about this in a later tutorial

protected override void ModNetworkStart(ModNetworkObject modNetworkObject)
{
base.ModNetworkStart(modNetworkObject);
}

This method is called when the network behaviour has it's own unique id and is ready to send data

protected override void ModNetworkPost(ModNetworkObject modNetworkObject)
{
base.ModNetworkPost(modNetworkObject);
}

This method is called after the network behaviour has been initalized. This is usually the safest area to instantly call RPCs if needed.

There is a lot you can do with these network behaviours but they are fundamental for any network communication in Wobbly Life.