#im following the codemonkey tutorial and

1 messages · Page 1 of 1 (latest)

late niche
#

@bright oak are the plates even NetworkObjects?

#

if they're not, that warning is not about them

rugged canopy
#

This is usually when an RPC is getting called before the object has spawned.

late niche
#

Where does .Spawn() get called for them then?

bright oak
#
public void SpawnKitchenObject(KitchenObjectSO kitchenObjectSO, IKitchenObjectParent kitchenObjectParent)
    {
        SpawnKitchenObjectServerRpc(GetKitchenObjectSOIndex(kitchenObjectSO), kitchenObjectParent.GetNetworkObject());
    }
    
    [ServerRpc(RequireOwnership = false)]
    private void SpawnKitchenObjectServerRpc(int kitchenObjectSOIndex, NetworkObjectReference kitchenObjectParentNetworkObjectReference)
    {
        KitchenObjectSO kitchenObjectSO = GetKitchenObjectSOFromIndex(kitchenObjectSOIndex);
        Transform KitchenObjectTransform = Instantiate(kitchenObjectSO.prefab);

        NetworkObject kitchenObjectNetworkObject = KitchenObjectTransform.GetComponent<NetworkObject>();
        kitchenObjectNetworkObject.Spawn(true);
        KitchenObject kitchenObject = KitchenObjectTransform.GetComponent<KitchenObject>();
        kitchenObjectParentNetworkObjectReference.TryGet(out NetworkObject kitchenObjectParentNetworkObject);
        IKitchenObjectParent kitchenObjectParent = kitchenObjectParentNetworkObject.GetComponent<IKitchenObjectParent>();

        kitchenObject.SetKitchenObjectParent(kitchenObjectParent);
    }

This piece of code is written on KitchenGameMultiplayer that contains functions like spawn kitchen objects or delete kitchen objects.

public override void Interact(Player player)
    {
        if (!player.HasKitchenObject())
        {
            if(platesSpawnedAmount > 0)
            {

                KitchenObject.SpawnKitchenObject(plateKitchenObjectSO,player);

                InteractLogicServerRpc();
            }
        }
    }

    [ServerRpc(RequireOwnership = false)]
    private void InteractLogicServerRpc()
    {
        InteractLogicClientRpc();
    }

    [ClientRpc]
    private void InteractLogicClientRpc()
    {
        platesSpawnedAmount--;

        OnPlateRemoved?.Invoke(this, EventArgs.Empty);
    }

This piece of code is inside the class PlateCounter.

bright oak
late niche
#

Yeah that’s not a bad guess.

bright oak
#

but i followed the tutorial step by step, and it happened all of a sudden this error

#

idk how

late niche
#

When does the warning show up?

bright oak
#

and it has no more animation on client side when it used to have it

bright oak
# late niche Never mind, don't think this is it.
public class ContainerCounter : BaseCounter
{
    public event EventHandler OnPlayerGrabbedObject;

    [SerializeField] private KitchenObjectSO kitchenObjectSO;

    public override void Interact(Player player)
    {
        if(!player.HasKitchenObject())
        {
            KitchenObject.SpawnKitchenObject(kitchenObjectSO, player);
            InteractLogicServerRpc();
        }
    }
    [ServerRpc(RequireOwnership =false)]
    private void InteractLogicServerRpc()
    {
        InteractLogicClientRpc();
    }

    [ClientRpc]
    private void InteractLogicClientRpc()
    {
        OnPlayerGrabbedObject?.Invoke(this, EventArgs.Empty);
    }
}
#

this is the piece of code for the player to interact with the container counter

late niche
#

What’s subscribed to OnPlayerGrabbedObject?

bright oak
#
public class ContainerCounterVisual : MonoBehaviour
{
    private const string OPEN_CLOSE = "OpenClose";
    [SerializeField] private ContainerCounter containerCounter;

    private Animator animator;

    private void Awake()
    {
        animator = GetComponent<Animator>();
    }

    private void Start()
    {
        containerCounter.OnPlayerGrabbedObject += ContainerCounter_OnPlayerGrabbedObject;
    }

    private void ContainerCounter_OnPlayerGrabbedObject(object sender, EventArgs e)
    {
        animator.SetTrigger(OPEN_CLOSE);
    }
}
#

only this

late niche
#

Yeah, I’m not sure.

#

No other warnings or errors show up?

bright oak
#
public class TrashCounter : BaseCounter
{
    public static event EventHandler OnAnyObjectTrashed;

    new public static void ResetStaticData()
    {
        OnAnyObjectTrashed = null;
    }

    public override void Interact(Player player)
    {
        if (player.HasKitchenObject())
        {
            KitchenObject.DestroyKitchenObject(player.GetKitchenObject());

            InteractLogicServerRpc();
            
        }
    }

    [ServerRpc(RequireOwnership = false)]
    private void InteractLogicServerRpc()
    {
        InteractLogicClientRpc();
    }

    [ClientRpc]
    private void InteractLogicClientRpc()
    {
        OnAnyObjectTrashed?.Invoke(this, EventArgs.Empty);
    }
}

Same error [Netcode] Deferred messages were received for a trigger of type OnSpawn with key 0, but that trigger was not received within within 1 second(s).
when i put a kitchen object in the trash.

#

and some errors in the client:

late niche
#

Can you find what NetworkObject matches those Hash numbers?

bright oak
#

i found them, what do i do?

late niche
#

Can you send what their components are? What scripts they have?

#

etc

bright oak
#

yes

late niche
#

Are all of these objects in the spawnable prefabs list?

bright oak
late niche
bright oak
#
public class BaseCounter : NetworkBehaviour, IKitchenObjectParent
{
    public static event EventHandler OnAnyObjectPlacedHere;

    public static void ResetStaticData()
    {
        OnAnyObjectPlacedHere = null;
    }

    [SerializeField] private Transform counterTopPoint;

    private KitchenObject kitchenObject;

    public virtual void Interact(Player player)
    {
        //Debug.LogError("BaseCounter.Interact();");
    }
    public virtual void InteractAlternate(Player player)
    {
        //Debug.LogError("BaseCounter.InteractAlternate();");
    }
    public Transform GetKitchenObjectFollowTransform()
    {
        return counterTopPoint;
    }

    public void SetKitchenObject(KitchenObject kitchenObject)
    {
        this.kitchenObject = kitchenObject;

        if (kitchenObject != null) OnAnyObjectPlacedHere?.Invoke(this, EventArgs.Empty);
    }

    public KitchenObject GetKitchenObject()
    {
        return kitchenObject;
    }

    public void ClearKitchenObject()
    {
        kitchenObject = null;
    }

    public bool HasKitchenObject()
    {
        return kitchenObject != null;
    }
    public NetworkObject GetNetworkObject()
    {
        return NetworkObject;
    }
}
late niche
#

Okay, that’s a NetworkBehaviour so that should be fine

#

Can you send your NetworkManager’s settings?

bright oak
#

yes

late niche
#

Yeah, I’m not really sure.

#

All of the simple things it could have been you seem to have done.

bright oak
#

ye

late niche
#

I don’t work with NGO that much so it’s hard for me to say without the project in front of me.

bright oak
#

and i dont know why all of a sudden all these things stopped working

bright oak
rugged canopy
bright oak
rugged canopy
bright oak
rugged canopy
bright oak
#

lemme try again

#

gotta remake the scene

#

fortunately i have the backup of the library folder of the last one

rugged canopy
bright oak
#

at this point i dont even know what to do to resolve this problem

#

the fact that the client is bugged

#

btw good night i gotta sleep, i'll see tomorrow what i can do

bright oak
#

im about to give up

#

i tried deleting the library but nothing resolved

rugged canopy
#

You're scenes disappeared when you deleted the Library folder? You might also want to try reinstalling the Editor

bright oak
#

and i found them

#

now i solved the error

#

finally

#

the problem was that the parent object has the networkBehaviour attached but not his child

#

why is that a problem?

rugged canopy
#

That shouldn't matter as long as the root parent object has a Network Object component

bright oak
#

and now i have no more errors

#

the fact is that there is another gameobject with the networkbehaviour but one of his child is not networkbehaviour and is not giving me any problems. How?

late niche
#

Can you send the scripts that are giving your problems?

bright oak
#

oh and thank yall for the help that you gave me in these days 😁