Skip to content

Allow [Command] functions to be called in server-only mode #3450

@miwarnec

Description

@miwarnec

This has been requested a lot, ever since UNET.

For example:

class Inventory : NetworkBehaviour
{
    // drop item at slot
    [Command]
    void DropItem(int slot) { ... }

   // local client may request to drop
   void Update()
   {
        if (isLocalPlayer && clicked) DropItem(4);
   }


   // server may want to call the code too
   [Server]
   void PunishPlayer()
   {
        // THIS ERRORS because commands can't be called on server-only
        for (i = 0 to count)
            DropItem(i);
   }
   ...

}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions