#im following the codemonkey tutorial and
1 messages · Page 1 of 1 (latest)
@bright oak are the plates even NetworkObjects?
if they're not, that warning is not about them
This is usually when an RPC is getting called before the object has spawned.
yes they are
Where does .Spawn() get called for them then?
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.
ye i know it's a lot of things, maybe the error is in
public override void Interact(Player player)
{
if (!player.HasKitchenObject())
{
if(platesSpawnedAmount > 0)
{
KitchenObject.SpawnKitchenObject(plateKitchenObjectSO,player);
InteractLogicServerRpc();
}
}
}
Yeah that’s not a bad guess.
but i followed the tutorial step by step, and it happened all of a sudden this error
idk how
Never mind, don't think this is it.
When does the warning show up?
when the client interacts with the container counter (the one who spawn the kitchen objects like cheese, bread...)
and it has no more animation on client side when it used to have 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
What’s subscribed to OnPlayerGrabbedObject?
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
lemme check
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:
Can you find what NetworkObject matches those Hash numbers?
yes
i found them, what do i do?
Are all of these objects in the spawnable prefabs list?
no because in the tutorial he didn't put them in
Can you send your Base Counter script?
yes
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;
}
}
Okay, that’s a NetworkBehaviour so that should be fine
Can you send your NetworkManager’s settings?
Yeah, I’m not really sure.
All of the simple things it could have been you seem to have done.
ye
I don’t work with NGO that much so it’s hard for me to say without the project in front of me.
and i dont know why all of a sudden all these things stopped working
dont worry man i appreciate the help 🙏
If you aren't seeing any compiler errors in the console. I would delete the Library folder and reimport.
wait, so i gotta make a backup of the library folder first
nah, Unity will recreate it on import
ye there is no more scene in the game no more game objects, no nothing
after you delete the folder, restart Unity
i did
lemme try again
gotta remake the scene
fortunately i have the backup of the library folder of the last one
weird. the Library folder does not contain any of the scenes
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
yo it's been days and i still didn't resolve the problem
im about to give up
i tried deleting the library but nothing resolved
You're scenes disappeared when you deleted the Library folder? You might also want to try reinstalling the Editor
nono they didn't disappear, i just had to search them throght the assets folder
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?
That shouldn't matter as long as the root parent object has a Network Object component
The root parent object has a Network Object component but not his children (they were MonoBehaviour) and that gave me problems of Hashcode. Now i put the networkbehaviour instead of the monobehaviour in all of his children
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?
Can you send the scripts that are giving your problems?
I solved them
oh and thank yall for the help that you gave me in these days 😁