#"Only server can spawn NetworkObjects" when attempting to spawn object through Rpc(SendTo.Server)

1 messages · Page 1 of 1 (latest)

steep hound
#

I'm very new to netcode so this is likely a silly mistake, if more info about the error is needed let me know (I'd provide it now but Unity is giving my computer issues)

somber haven
#

is this script a valid NetworkBehaviour at the time you call this RPC?

#
  • has a NetworkObject attached to it
  • is Spawned at the time of calling the RPC
  • the script inherits from NetworkBehaviour
steep hound
#

this class gets instantiated and added to a list declared in a NetworkObject

#

i don't believe the class itself is spawned, but the object holding it certainly is

#

and they both inherit NetworkBehaviour yeah

summer hazel
#

The network behavior needs to be on the network object when it has been spawned. You can not add one after it has been spawned

steep hound
#

even if the networkbehavior isn't a component?

#

i have it added to a dictionary inside a script that is already on the object before its spawned

summer hazel
#

you could add it as a child object to the main game object before it spawns though

steep hound
#

ahhh i see