docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Understanding ownership and authority

    By default, Netcode for GameObjects assumes a client-server topology, in which the server owns all NetworkObjects (with some exceptions) and has ultimate authority over spawning and despawning.

    Checking for authority

    IsServer

    IsServer or !IsServer is the traditional client-server method of checking whether the current context has authority.

    public class MonsterAI : NetworkBehaviour
    {
        public override void OnNetworkSpawn()
        {
            if (!IsServer)
            {
                return;
            }
            // Server-side monster init script here
            base.OnNetworkSpawn();
        }
    
        private void Update()
        {
            if (!IsSpawned || !IsServer)
            {
                return;
            }
            // Server-side updates monster AI here
        }
    }
    
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)