Search Unity

Hello World Part two - HelloWorldPlayer scripts with errors

Discussion in 'Netcode for GameObjects' started by UnitySombra, Oct 21, 2021.

  1. UnitySombra

    UnitySombra

    Joined:
    Sep 2, 2017
    Posts:
    3
    Hi all, today I was to trying multiplayer with Unity. I found Netcode and while reading the documentation and doing the Hello World initial project, I encounter a couple of errors. In the HelloWorldPlayer script pop up like 8 errors. I install version 1.0.0-pre.2.

    1. Assets\Scripts\HelloWorldPlayer.cs(2,21): error CS0234: The type or namespace name 'Messaging' does not exist in the namespace 'Unity.Netcode' (are you missing an assembly reference?)
    2. Assets\Scripts\HelloWorldPlayer.cs(3,21): error CS0305: Using the generic type 'NetworkVariable<T>' requires 1 type arguments
    3. Assets\Scripts\HelloWorldPlayer.cs(16,30): error CS0115: 'HelloWorldPlayer.NetworkStart()': no suitable method found to override
    4. Assets\Scripts\HelloWorldPlayer.cs(10,16): error CS0246: The type or namespace name 'NetworkVariableVector3' could not be found (are you missing a using directive or an assembly reference?)
    For example in the 2nd error I found that instead NetworkVariableVector3 I should use NetworkVariable<Vector3>...

    Where can I found the updated documentation?

    Code (CSharp):
    1. using Unity.Netcode;
    2. using Unity.Netcode.Messaging;
    3. using Unity.Netcode.NetworkVariable;
    4. using UnityEngine;
    5.  
    6. namespace HelloWorld
    7. {
    8.     public class HelloWorldPlayer : NetworkBehaviour
    9.     {
    10.         public NetworkVariableVector3 Position = new NetworkVariableVector3(new NetworkVariableSettings
    11.         {
    12.             WritePermission = NetworkVariablePermission.ServerOnly,
    13.             ReadPermission = NetworkVariablePermission.Everyone
    14.         });
    15.                
    16.         public override void NetworkStart()
    17.         {
    18.             Move();
    19.         }

    This is the link to the documentation part
    https://docs-multiplayer.unity3d.co...wo#adding-basic-movement-to-the-player-object
     
  2. luke-unity

    luke-unity

    Joined:
    Sep 30, 2020
    Posts:
    306
    Yeah sorry about that, a few things are still out of date in the Hello World. We'll fix it asap.
     
    UnitySombra likes this.
  3. UnitySombra

    UnitySombra

    Joined:
    Sep 2, 2017
    Posts:
    3
    Thanks for the quick response!
     
  4. luke-unity

    luke-unity

    Joined:
    Sep 30, 2020
    Posts:
    306
    Forgot to answer here, Hello World should be fully working now.
     
    UnitySombra likes this.