Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    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:
    69
    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:
    4,316
    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.