Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved ServerRpc method must end with 'ServerRpc' suffix

Discussion in 'Netcode for GameObjects' started by HuginnRaven, Apr 19, 2023.

  1. HuginnRaven

    HuginnRaven

    Joined:
    Dec 20, 2015
    Posts:
    33
    I'm using Unity 2023.1.0b9, so I know this might be an error because of that as I'm living on the bleeding edge, but I'm using a new multiplayer testing feature and that's why I'm doing it.

    With that out of the way. The error is as the title reads: "error -ServerRpc method must end with 'ServerRpc' suffix"
    But it also says: "
    PostProcessing failed: Unity.ILPP.Runner.ILPostProcessorDiagnosticsException: Unity.Netcode.Editor.CodeGen.NetworkBehaviourILPP: Assets\Game\Scripts\Player\WeaponSystem.cs(59,9): error - ServerRpc method must end with 'ServerRpc' suffix!"

    The offending code looks as follows:
    Code (CSharp):
    1. [ServerRpc]
    2. private void SpawnMissile(Vector3 spawnPos, Direction lastMove, ServerRpcParams rpcParams = default)
    3.         {
    4.                //Left empty, there's nothing here. The error is not here.
    5.         }
    Quick edit: I can remove all parameters, or only include the ServerRpcParams and the error still exists.
     
  2. Evil-Otaku

    Evil-Otaku

    Joined:
    Oct 17, 2012
    Posts:
    71
    It's referring to the name of the function that must end in 'ServerRpc'
     
    HuginnRaven likes this.
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,533
    The error is correct.

    Rename the method to: SpawnMissileServerRpc
     
    HuginnRaven likes this.
  4. HuginnRaven

    HuginnRaven

    Joined:
    Dec 20, 2015
    Posts:
    33
    Ooooooh! I remember reading that, thinking "don't tell me what to do"... but now it's demanding it. Got it. Thanks.