Deferred messages were received for a trigger of type OnAddPrefab

[Netcode] Deferred messages were received for a trigger of type OnAddPrefab with key 227838193, but that trigger was not received within within 1 second(s).
UnityEngine.Debug:LogWarning (object)
Unity.Netcode.NetworkLog:LogWarning (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Logging/NetworkLog.cs:28)
Unity.Netcode.DeferredMessageManager:PurgeTrigger (Unity.Netcode.IDeferredNetworkMessageManager/TriggerType,ulong,Unity.Netcode.DeferredMessageManager/TriggerInfo) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/DeferredMessageManager.cs:97)
Unity.Netcode.DeferredMessageManager:CleanupStaleTriggers () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Messaging/DeferredMessageManager.cs:82)
Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs:82)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:192)
Unity.Netcode.NetworkUpdateLoop/NetworkPostLateUpdate/<>c:<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkUpdateLoop.cs:287)
using UnityEngine;
using Unity.Netcode;

public class ProjectileLauncher : NetworkBehaviour
{
    public GameObject projectilePrefab;  // The projectile prefab to shoot
    public Transform shootPoint;         // The point where the projectile will be spawned
    public float shootForce = 30f;       // The force applied to the projectile

    [SerializeField]
    private GameObject orientation;      // Direction from where to launch the projectile

    private ulong ownerClientID;

    private void Start()
    {
        // Get the client ID of the player who owns this object
        ownerClientID = GetComponent<NetworkObject>().OwnerClientId;
        Debug.Log("ProjectileLaucher OwnerClientID: " + ownerClientID);
    }

    public void ShootProjectile()
    {   
        SpawnProjectileServerRPC();
    }

    [ServerRpc(RequireOwnership = false)]
    private void SpawnProjectileServerRPC()
    {
        GameObject projectile = Instantiate(projectilePrefab, shootPoint.position, shootPoint.rotation);

        projectile.GetComponent<NetworkObject>().SpawnWithOwnership(GetComponent<NetworkObject>().OwnerClientId);
        Debug.Log("Projectile spawned with ownership for client ID: " + ownerClientID);

        Rigidbody projectileRb = projectile.GetComponent<Rigidbody>();
        if (projectileRb != null)
        {
            projectileRb.AddForce(orientation.transform.forward * shootForce, ForceMode.Impulse);
            Debug.Log("Applied force to projectile Rigidbody.");
        }
    }
}

I used [ServerRpc] to spawn objects on the server, but the SpawnWithOwnership() is not spawning the object across the network.

Is that prefab in the network prefabs list?

I think the “not received” also occurs when trying to send an RPC from an object that hasn’t spawned yet.

Don’t call or use Network methods in Awake or Start. This object may not have spawned yet and thus the owner client id may not be set yet. Move that code in OnNetworkSpawn to make sure it runs first thing after the object spawned.

Note that the ownerClientId may be different than GetComponent<NetworkObject>().OwnerClientId. Avoid logging one thing but using another in code:

var ownerId = GetComponent<NetworkObject>().OwnerClientId;
projectile.GetComponent<NetworkObject>().SpawnWithOwnership(ownerId);
Debug.Log("Projectile spawned with ownership for owner client ID: " + ownerId);

I changed the code to use OnNetworkSpawn() and the ownerID change. I also changed the NetworkPrefabsList from the default one to a new one and it seems to work, but it greets me with a new error.

[Netcode] [Invalid Destroy][TeleportOrb(Clone)][NetworkObjectId:22] Destroy a spawned NetworkObject on a non-host client is not valid. Call Destroy or Despawn on the server/host instead.
UnityEngine.Debug:LogError (object)
Unity.Netcode.NetworkLog:LogError (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Logging/NetworkLog.cs:34)
Unity.Netcode.NetworkLog:LogServer (string,Unity.Netcode.NetworkLog/LogType) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Logging/NetworkLog.cs:91)
Unity.Netcode.NetworkLog:LogErrorServer (string) (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Logging/NetworkLog.cs:52)
Unity.Netcode.NetworkObject:OnDestroy () (at ./Library/PackageCache/com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs:745)


I think this is caused by the Destroy call in the start function.

using UnityEngine;
using Unity.Netcode;

public abstract class ProjectileBase : NetworkBehaviour
{
    public float maxLifetime = 5f;       
    //public GameObject impactEffect;      
    public LayerMask hitMask;         

    private Rigidbody rb;

    void Start()
    {
        Destroy(gameObject, maxLifetime);
    }

    void OnCollisionEnter(Collision collision)
    {
        if (((1 << collision.gameObject.layer) & hitMask) != 0)
        {
            //ImpactEffect(collision.contacts[0].point);

            ExecuteHit(collision.gameObject, collision.contacts[0].point);

            Destroy(gameObject);
        }
    }

    public abstract void ExecuteHit(GameObject hit,Vector3 hitPos);
}

How would i do the destroy call? Mabye through a coroutine?