mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 19:10:32 +00:00
35fee94d56
* Moved doc files to docfx folder * load csproj * doc generation * Run docfx * Add docfx * Deploy docs to mirror-networking.com * use deploy phase * deploy whole generated site * Fixed the semantic release command * Is last \ required? * show debug log * using lftp for site deploy * Testing lftp * Show current folder * try -e command option * Show me the files * use plain ftp * use choco install instead of cinst * fix ssl certificate validation * fix username * Upload site to xmldocs folder * no need to archive docs * No need for debug output * Fix file permissions * show me .htaccess * Show me contents * Wipe out folder to fix permissions * Set file permissions * Fix file permissions * complete toc list * Migrated intro page * Remove old docs * Update link to docs * Add link to github * Only update docs for stuff in master * This is a powershell command * Update doc/articles/Concepts/Communications/RemoteActions.md * Update doc/articles/Concepts/VisibilityCustom.md * Update doc/articles/Concepts/Authority.md * Update doc/articles/Concepts/GameObjects/SpawnObjectCustom.md * Update doc/articles/Concepts/Authority.md * Update doc/articles/Classes/SyncVars.md * No need to run semver twice
93 lines
3.0 KiB
Markdown
93 lines
3.0 KiB
Markdown
# Converting a Single-Player Game to Mirror
|
||
|
||
This document describes steps to converting a single player game to a multiplayer game, using Mirror. The process described here is a simplified, higher level version of the actual process for a real game; it doesn’t always work exactly like this, but it provides a basic recipe for the process.
|
||
|
||
## NetworkManager set-up
|
||
|
||
- Add a new game object and rename it “NetworkManager”.
|
||
- Add the NetworkManager component to the “NetworkManager” game object.
|
||
- Add the NetworkManagerHUD component to the game object. This provides the default UI for managing the network game state.
|
||
|
||
See Using the NetworkManager.
|
||
|
||
## Player Prefab Setup
|
||
|
||
- Find the Prefab for the player game object in the game, or create a Prefab from the player game object
|
||
- Add the NetworkIdentity component to the player Prefab
|
||
- Check the LocalPlayerAuthority box on the NetworkIdentity
|
||
- Set the `playerPrefab` in the NetworkManager’s Spawn Info section to the player Prefab
|
||
- Remove the player game object instance from the Scene if it exists in the Scene
|
||
|
||
See Player Objects for more information.
|
||
|
||
## Player Movement
|
||
|
||
- Add a NetworkTransform component to the player Prefab
|
||
- Update input and control scripts to respect `isLocalPlayer`
|
||
- Fix Camera to use spawned player and `isLocalPlayer`
|
||
|
||
For example, this script only processes input for the local player:
|
||
|
||
```cs
|
||
using UnityEngine;
|
||
using Mirror;
|
||
|
||
public class Controls : NetworkBehaviour
|
||
{
|
||
void Update()
|
||
{
|
||
if (!isLocalPlayer)
|
||
{
|
||
// exit from update if this is not the local player
|
||
return;
|
||
}
|
||
|
||
// handle player input for movement
|
||
}
|
||
}
|
||
```
|
||
|
||
## Basic Player Game State
|
||
|
||
- Make scripts that contain important data into NetworkBehaviours instead of MonoBehaviours
|
||
- Make important member variables into SyncVars
|
||
|
||
See State Synchronization.
|
||
|
||
## Networked Actions
|
||
|
||
- Make scripts that perform important actions into NetworkBehaviours instead of MonoBehaviours
|
||
- Update functions that perform important player actions to be commands
|
||
|
||
See Networked Actions.
|
||
|
||
## Non-player Game Objects
|
||
|
||
Fix non-player prefabs such as enemies:
|
||
|
||
- Add the NetworkIdentify component
|
||
- Add the NetworkTransform component
|
||
- Register spawnable Prefabs with the NetworkManager
|
||
- Update scripts with game state and actions
|
||
|
||
## Spawners
|
||
|
||
- Potentially change spawner scripts to be NetworkBehaviours
|
||
- Modify spawners to only run on the server (use isServer property or the `OnStartServer()` function)
|
||
- Call `NetworkServer.Spawn()` for created game objects
|
||
|
||
## Spawn Positions for Players
|
||
|
||
- Add a new game object and place it at player’s start location
|
||
- Add the NetworkStartPosition component to the new game object
|
||
|
||
## Lobby
|
||
|
||
- Create Lobby Scene
|
||
- Add a new game object to the Scene and rename it to “NetworkLobbyManager”.
|
||
- Add the NetworkLobbyManager component to the new game object.
|
||
- Configure the Manager:
|
||
- Scenes
|
||
- Prefabs
|
||
- Spawners
|