Last updated
Last updated
Keep in mind that both PurrNet and FishNet are systems which are constantly evolving and could be prone to change.
Converting from FishNet to PurrNet is likely as simple as it gets. A lot of the naming conventions from FishNet are similar to those in PurrNet.
It is recommended doing the conversion in a separate project in order to use the "old" project for comparison.
Make sure your project is backed up prior to beginning any conversion!
Both FishNet and PurrNet have a component, which needs to be present for you to start acting on the network. FishNet's network manager can hold several components like:
Network Manager
Transport(s)
Observer Manager
Client Manager
Server Manager
Time Manager
Statistics Manager
Prediction Manager
etc. etc.
PurrNet utilizes internal manager classes for our Network Manager setup, meaning you generally only need your Network Manager object to hold 2 components:
Network Manager
Transport
A major difference between FishNet and PurrNet, is the understanding of ownership and networked objects/identities. In FishNet, NetworkObjects are automatically added to the root of any object that needs to act on the network. Though this adds a solid level of simplicity to the understanding of something like ownership, it can also easily impose some limitations to the developer. For example:
β Can't nest prefabs that are both network objects, as there can only be one NetworkObject per prefab. βCan't have different owners per component
βοΈ Can nest prefabs, whether they are networked or not βοΈ Can have split ownership on a gameobject across several components
Handling new objects or removing existing networked objects is a bit different between the systems. In FishNet, you'd need to instantiate the object and spawn the attached NetworkObject component. And if you'd want to spawn with ownership, it would be added as a parameter to the spawn call. That would look like this:
It's similar for despawning where you have to call the despawn method for the NetworkObject component.
In PurrNet, spawning and despawning is handled for you, meaning that if you just want to spawn an object, any networked action handled for that object in the same tick, will arrive with the spawn packet. So spawning with ownership using PurrNet would look like this:
RPC's also hold parameters, this is slightly different but mostly the same. FishNet
PurrNet
There are few functional differences with some of them, for example the SyncTimer of PurrNet handles reconciliation, ensuring that the timers align on clients and doesn't get de-synced
So setting up your Network Manager with PurrNet is as easy as making a new gameObject in your scene and adding the Network Manager. See the page for more info.
In PurrNet every networked component stands on its own, meaning that every networked component () can have individual ownership, and be nested exactly as you would with the normal Unity workflow. For example:
And despawning in PurrNet is as easy as calling Destroy on the object as you would normally in Unity. Give the specific page on a read for a more in depth explanation.
Working with RPC's when transitioning from FishNet to PurrNet is extremely easy, as the naming conventions are the exact same. However, there are some key differences in terms of usage. This will however depend on your so make sure to read up on those. If you are running with a rule set similar to the default "ServerStrict" rules, then the usage will be the same. But if you're running with a rule set similar to the "Unsafe" rules, then you can send any RPC directly from any client!
PurrNet also has more options in terms of RPC usage than FishNet. For example, PurrNet also has , and . All of which can also be used and even combined as needed.
Working with Synchronizing from FishNet to PurrNet is generally the same as well. The major difference between the two, is that PurrNet also allows for owner authorized SyncTypes, meaning you can handle them locally, and not forcibly through the server. You can read more on his on the individual page for the SyncTypes. Our SyncTypes are built using the of PurrNet, however, usage wise they are nearly identical.
Callbacks in FishNet are found on the respective manager component which the NetworkManager works with. Using PurrNet, all the callbacks are found in the itself. The video on the found on the relative page, explains this more in depth. Using your IDE should give you access to all the callbacks you need.
[ServerRpc]
[ServerRpc]
[ObserversRpc]
[ObserversRpc]
[TargetRpc]
[TargetRpc]
SyncVar
SyncList
SyncHashSet
SyncDictionary
SyncTimer