Search Unity

Question Can't get NetCode "Getting Started" project working

Discussion in 'NetCode for ECS' started by Edvard-D, May 24, 2020.

  1. Edvard-D

    Edvard-D

    Joined:
    Jun 14, 2012
    Posts:
    129
    I worked through the "Getting Started" example project, but when I tried testing it it doesn't seem to work. To be more specific, the "SharedData" object and its children (such as the plane that represents the floor) all disappear and nothing is spawned. I have "Client & Server" selected as the multiplayer PlayMode type.

    Along with that, I get the following error message. "Gallery" is the Name Prefix value in the GhostCollectionAuthoringComponent. There is no "GalleryGhostReceiveSystem" script in the project; is this being generated at runtime or something?

    Code (CSharp):
    1. ArgumentException: Unknown Type:`GalleryGhostReceiveSystem` All ComponentType must be known at compile time. For generic components, each concrete type must be registered with [RegisterGenericComponentType].
    2. Unity.Entities.TypeManager.GetTypeIndex[T] () (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/Types/TypeManager.cs:576)
    3. Unity.Entities.ComponentType.ReadWrite[T] () (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/Types/ComponentType.cs:33)
    4. Unity.Entities.ComponentType.ReadOnly[T] () (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/Types/ComponentType.cs:60)
    5. Unity.Entities.ComponentSystemBase.RequireSingletonForUpdate[T] () (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/ComponentSystemBase.cs:497)
    6. RockMine.Gallery.AgentInputSampleSystem.OnCreate () (at Assets/_Project/Agent/AgentInputSampleSystem.cs:13)
    7. Unity.Entities.ComponentSystemBase.CreateInstance (Unity.Entities.World world) (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/ComponentSystemBase.cs:124)
    8. Unity.Entities.World.AddSystem[T] (T system) (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/World.cs:471)
    9. Unity.Entities.World.CreateSystemInternal (System.Type type, System.Object[] constructorArguments) (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/World.cs:374)
    10. Unity.Entities.World.GetOrCreateSystemInternal (System.Type type) (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/World.cs:390)
    11. Unity.Entities.World.GetOrCreateSystem (System.Type type) (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities/World.cs:418)
    12. Unity.NetCode.ClientServerBootstrap.CreateClientWorld (Unity.Entities.World defaultWorld, System.String name) (at Library/PackageCache/com.unity.netcode@0.1.0-preview.6/Runtime/ClientServerWorld/ClientServerBootstrap.cs:85)
    13. Unity.NetCode.ClientServerBootstrap.Initialize (System.String defaultWorldName) (at Library/PackageCache/com.unity.netcode@0.1.0-preview.6/Runtime/ClientServerWorld/ClientServerBootstrap.cs:51)
    14. Unity.Entities.DefaultWorldInitialization.Initialize (System.String defaultWorldName, System.Boolean editorWorld) (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:110)
    15. Unity.Entities.AutomaticWorldBootstrap.Initialize () (at Library/PackageCache/com.unity.entities@0.7.0-preview.19/Unity.Entities.Hybrid/Injection/AutomaticWorldBootstrap.cs:15)
    In case it's helpful, I'm using version 0.7.0 of the Entities package.
     
  2. Edvard-D

    Edvard-D

    Joined:
    Jun 14, 2012
    Posts:
    129
    Well, I figured out that the entities still exist and that the player has been spawned as well. I'm new to DOTS and forgot that the GameObjects disappear and are replaced by entities that can only be seen in the Entity Debugger. There I can see that there are two worlds: DefaultWorld and ClientWorld0. DefaultWorld has no entities in it, they're all in ClientWorld0. Does this have something to do with the camera rendering DefaultWorld instead of ClientWorld0?
     
  3. Edvard-D

    Edvard-D

    Joined:
    Jun 14, 2012
    Posts:
    129
    Did some more digging around and am pretty sure the problem is related to the error message I'm getting. At least in the sense that there's code that stops executing when the error is thrown.

    I printed some Debug.Log messages in the "Game" system that can be seen under the "Establish a connection" section. I had it display "World.AllWorlds.Count" to see how many worlds are being created depending on what PlayMode I select in the multiplayer settings. When I select either "Client & Server" or "Client," two worlds exist. When I set it to "Server" only, seven worlds exist. Also, when I select "Client & Server" as the PlayMode type, the Entity Debugger only displays DefaultWorld and ClientWorld0. When I select "Server" the two worlds are DefaultWorld and ServerWorld. That means SeverWorld should also exist when "Client & Server" is selected, but it's not being created.

    I think if I can fix this error message I can get this working.
     
  4. LazyMan

    LazyMan

    Joined:
    Dec 7, 2013
    Posts:
    26
    Looks like somewhere around Assets/_Project/Agent/AgentInputSampleSystem.cs you have variable and/or component with wrong type.
    Double check it.
    So, another one: Generics. Use it gentle ;)
     
    Edvard-D likes this.
  5. Edvard-D

    Edvard-D

    Joined:
    Jun 14, 2012
    Posts:
    129
    Ahhhh okay, thanks for pointing that out! The line in question is this line of the SampleCubeInput class in the tutorial:

    Code (CSharp):
    1. RequireSingletonForUpdate<EnableNetCubeGhostReceiveSystemComponent>();
    The "NetCube" part of the name in that component corresponds with the "Name Prefix" field of the GhostCollectionAuthoringComponent. In my case this should be "Gallery." It was throwing an error saying it doesn't exist, which is because... it didn't exist. I had forgotten "Component" at the end of "EnableGalleryGhostReceiveSystemComponent".

    Everything's sorted and in working order now. Thanks again for your help!
     
  6. LazyMan

    LazyMan

    Joined:
    Dec 7, 2013
    Posts:
    26
    You're welcome! Have a good day, and good luck!
     
  7. Kirkules_

    Kirkules_

    Joined:
    Aug 5, 2014
    Posts:
    65
    I'm having the same problem, I don't understand your solution.
    My GhostAuthoringComponent Name field has: MovableCube
    If I use EnableMovableCubeGhostReceiveSystemComponent as a type in the line:
    RequireSingletonForUpdate<EnableMovableCubeGhostReceiveSystemComponent>();
    it still doesn't exist, and has a compile error.
     
    Last edited: Aug 24, 2020