Quick Samples

Some simple scripts covering different networking needs that you may find useful:

A simple spawn script that Instantiates the Networked Player on a keypress.
Simple Input to get your Game Objects moving.
An Event System you put on the Prefab with coherenceSync
that can handle Network Commands and transfer Authority.
An Event System you put on an empty Game Object in your 
Scene that handles Global Connection/Disconnection.

Keeps a score that is synced across the Network.

Display a name tag above all player characters with their name. 
Put this script on your player character and populate the nameTagPrefab variable (a basic TextMeshPro Object will do fine). 
You also need to sync the playerName variable through the coherence Configuration tab. 
Following the previous example, put this line of code in the Update() function to have the UI always face the camera. 
This method returns a random position off screen (in 2D!). Very useful for spawning enemies off screen in your prototypes.
When set up, this script will display a sprite (an arrow for example) on the edge of the screen, indicating that something is off screen.

To set it up, create a GameObject and attach this script and a SpriteRenderer to it. Put what you want to track into subject, and you're good to go!

Last updated