Fish-Net: Networking Evolved
  • Introduction
    • Getting Started
    • Showcase
      • Upcoming Releases
    • Legal Restrictions
    • Pro, Projects, and Support
    • Business Support
    • Branding
  • Manual
    • General
      • Unity Compatibility
      • Changelog
        • Development Road Map
        • Major Version Update Solutions
      • Development
      • Performance
        • Benchmark Setup
        • Fish-Networking Vs Mirror
      • Terminology
        • Miscellaneous
        • Communicating
        • Server, Client, Host
      • Transports
      • Add-ons
        • Edgegap and other Hosting
        • Fish-Network-Discovery
      • Feature Comparison
      • Upgrading To Fish-Networking
    • Guides
      • Frequently Asked Questions (FAQ)
      • Creating Bug Reports
        • Report Example
      • Technical Limitations
      • Third-Party
      • Getting Started
        • Commonly Used Guides
        • Ownership - Moving Soon
        • Step-by-Step
          • Getting Connected
          • Preparing Your Player
      • Components
        • Managers
          • NetworkManager
          • TimeManager
          • PredictionManager
          • ServerManager
          • ClientManager
          • SceneManager
          • TransportManager
            • IntermediateLayer
          • StatisticsManager
          • ObserverManager
            • HashGrid
          • RollbackManager (Pro Feature)
        • Transports
          • FishyWebRTC
          • Bayou
          • FishyEOS (Epic Online Services)
          • FishyFacepunch (Steam)
          • FishyRealtime
          • FishySteamworks (Steam)
          • FishyUnityTransport
          • Multipass
          • Tugboat
          • Yak (Pro Feature)
        • Prediction
          • Network Collider
            • NetworkCollision
            • NetworkCollision2D
            • NetworkTrigger
            • NetworkTrigger2D
          • OfflineRigidbody
          • PredictedOwner
          • PredictedSpawn
        • Utilities
          • Tick Smoothers
            • NetworkTickSmoother
            • OfflineTickSmoother
          • MonoTickSmoother [Obsolete]
          • DetachableNetworkTickSmoother [Obsolete]
          • BandwidthDisplay
          • DefaultScene
          • PingDisplay
        • Authenticator
        • ColliderRollback
        • NetworkAnimator
        • NetworkBehaviour
        • NetworkTransform
        • NetworkObject
        • NetworkObserver
      • InstanceFinder
      • Ownership
        • Using Ownership To Read Values
      • Spawning and Despawning
        • Predicted Spawning
        • Nested NetworkObjects
        • Object Pooling
      • Components
      • NetworkBehaviour
      • NetworkObjects
      • Attributes, Quality of Life
      • Remote Procedure Calls
        • Broadcast
      • SyncTypes
        • Customizing Behavior
        • SyncVar
        • SyncList
        • SyncHashSet
        • SyncDictionary
        • SyncTimer
        • SyncStopwatch
        • Custom SyncType
      • Observers
        • Modifying Conditions
        • Custom Conditions
      • Automatic Serializers
      • Custom Serializers
        • Interface Serializers
        • Inheritance Serializers
      • Addressables
      • Scene Management
        • Scene Events
        • Scene Data
          • SceneLookupData
          • SceneLoadData
          • SceneUnloadData
        • Loading Scenes
        • Unloading Scenes
        • Scene Stacking
        • Scene Caching
        • Scene Visibility
        • Persisting NetworkObjects
        • Custom Scene Processors
          • Addressables
      • Transports
        • Multipass
      • Prediction
        • What Is Client-Side Prediction
        • Configuring PredictionManager
        • Configuring TimeManager
        • Configuring NetworkObject
        • Offline Rigidbodies
        • Interpolations
        • Creating Code
          • Controlling An Object
          • Non-Controlled Object
          • Understanding ReplicateState
            • Using States In Code
            • Predicting States In Code
          • Advanced Controls
        • Custom Comparers
        • PredictionRigidbody
        • Using NetworkColliders
      • Lag Compensation
        • States
        • Raycast
        • Projectiles
    • Server Hosting
      • Edgegap - Official Partner
        • Getting Started with Edgegap
      • Hathora
        • Getting Started with Hathora
      • Amazon Web Services (AWS)
        • Getting Started with AWS
    • API
Powered by GitBook
On this page
  • Step-by-Step Guide
  • Before You Begin
  • Create a Player Game Object
  • Setup the Player Object for Spawning
  • Add Spawn Points
  • Test the Player Spawning
  1. Manual
  2. Guides
  3. Getting Started
  4. Step-by-Step

Preparing Your Player

Spawn an object over the network to represent each client's player.

PreviousGetting ConnectedNextComponents

Last updated 19 days ago

For many games you will want to have a player object for each client. This guide will walk you through the process step by step.

Step-by-Step Guide

Before You Begin

Ensure that you're not in Play Mode in the Unity Editor. Making changes during Play Mode will not persist after exiting.

Create a Player Game Object

In the Unity Scene Hierarchy, create a new 3D object of type Capsule. Select the capsule in the Hierarchy and rename it to Player. In the Inspector, click on Add Component and search for NetworkObject. Add the NetworkObject component to the capsule.

Explanation:

The NetworkObject component is required for linking a game object over the network. It enables the object to synchronize its state across clients and the server.

Setup the Player Object for Spawning

Drag the player game object into the project hierarchy to turn it into a prefab, then delete the game object from the scene.

Select the NetworkManager in the scene and assign your new Player prefab into the Player Prefab field on the PlayerSpawner component.

Add Spawn Points

Create two empty Game Objects in the scene to act as spawn points. Position them where you'd like players to spawn on the map. Add these Game Objects as Transform references to the PlayerSpawner component in the Spawns list field.

Explanation:

The PlayerSpawner uses these transforms to determine spawn locations, choosing them in order from top to bottom for each subsequent player and beginning again after reaching then final spawn point. If no spawn points are specified, the spawner defaults to using the prefab's transform properties for placement.

Test the Player Spawning

Save the scene and press the Play button in the Unity Editor. As soon as the server and client starts you should see the a capsule spawning as the player object at the location of the first spawn point. To see another player spawn you can build and run the game and which will then automatically connect as a client to the editor. You should then see a second player capsule spawn for the second player at the second spawn point.

Don't worry if you encounter an error in a second game window stating: "Server failed to start. This usually occurs when the specified port is unavailable, be it closed or already in use.". This occurs because multiple instances are attempting to start as a server on the same machine using the same port. Only the first instance will succesfully start as a server and the rest will instead start as clients only, thus this error is safe to ignore for local testing.

Alternatively, you can launch a second Unity Editor instance by using package or a third party package such as .

Unity's Multiplayer Play Mode
ParrelSync
NetworkObject component added to capsule
Turn the Player Object into a Prefab
Assign Player Prefab in Player Spawner
Create and Assign Spawn Points
Built Game Connected to Editor
Multiplayer Play Mode Connected to Editor
NetworkObject component added to capsule
Turn the Player Object into a Prefab
Assign Player Prefab in Player Spawner
Create and Assign Spawn Points
Built Game Connected to Editor
Multiplayer Play Mode Connected to Editor