- Home /
Calling [Command] from an attached NetworkBehaviour does not work?
Hello everyone. I'm currently working on a multiplayer game and I'm having some trouble with the networking part. I have a player game object that gets spawned with the appropriate permissions and basically works. Next, I added code to attach scripts to the player based on which ability he picked up as the game is running. These scripts derive from NetworkBehaviour
. This way, I should be able to use [Command]
and [Server]
attributes in them for the abilities I want to spawn something for (using NetworkServer
). Note that when the player picks up an ability, the script gets attached to the player on all the clients and server.
However, when using the [Command]
attribute on a function, I notice that it gets executed on the client and does not get called on the server. I get warnings for the code marked with [Server]
. My suspicion is that since I'm attaching a script to an object that already exists when the game started, the command call fails. Does anyone know if that might be the case?
Answer by Rex240 · Jun 07, 2018 at 08:09 PM
I think I may have found the answer, though it was not what I was hoping for. Unless Unity's networking API has changed since 2015, this may be the to why my class could not call Commands.
http://answers.unity.com/answers/1094373/view.html
EDIT: If someone can confirm this for me, I'll close the thread.
Your answer
Follow this Question
Related Questions
How Client send info to Host in Unity Multiplayer 0 Answers
[C#] Unet spawn dont work. 0 Answers
How to add Multipeer support between iOS and Windows? 0 Answers
Help!How to make own UNet server on the Internet? 0 Answers
Getting Gameobjects in Unet 1 Answer