Search Unity

Resolved (IN-18511) [1.0.0-exp.8] Prespawn ghost feature makes manual spawn ghost not working properly

Discussion in 'NetCode for ECS' started by optimise, Oct 2, 2022.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    At 1.0 preview release prespawn ghost feature will make manual spawn not working properly. I just reproduce it with simple netcube project that when I add a prespawn ghost, manually spawn netcode that set to auto command if I remember correctly will throw at lots of CubeInput error.
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    could you please explain a little more the setup? I didn't actually understood what you were trying to do.
    What kind of prespawn you put in the scene?

    OwnerPredicted pre-spawned ghosts are not allowed (we log conversion error in that case IIRC). But predicted ghost with owner and and with auto-command may be still allowed, and that may break the auto-command assignment.
    So it doesn't looks like it is the pre-spawns th problem in itself but the fact there are two or more entity (now) with auto-command target enabled. And that may be causing the error in the NetCube sample.

    Also please report the bug using the the bug report tool so we can track it. Thanks!
     
  3. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    What I want to say is the same setup at Netcube project is working at 0.51 but not working at 1.0 anymore. Netcube is owner predicted and spawn manually. It's working properly until u change the setup that u add another interpolate ghost to be prespawn ghost then tat manual spawn owner predicted ghost starts to not working properly anymore. If u still can't reproduce it I will try to report bug.
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    mmm. If I do the same things everything still work perfectly fine in NetCube sample. There is definitively something different you are doing.
    Can you share some screenshoot of the prefabs?
     
  5. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Submitted bug report IN-18511. Check it out. Looks like something wrong that it has another same copy for each ghost.

    upload_2022-10-3_11-4-50.png

    Error spam when added prespawn ghost:
    ArgumentException: A component with type:CubeInput [Buffer] has not been added to the entity. Entities Journaling may be able to help determine more information. Please enable Entities Journaling for a more helpful error message.
    Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, Unity.Entities.ComponentType componentType) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/EntityComponentStoreDebug.cs:301)
    Unity.Entities.EntityComponentStore.AssertEntityHasComponent (Unity.Entities.Entity entity, Unity.Entities.TypeIndex componentType) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/EntityComponentStoreDebug.cs:323)
    Unity.Entities.BufferLookup`1[T].get_Item (Unity.Entities.Entity entity) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/Iterators/BufferLookup.cs:217)
    MoveCubeSystem.OnUpdate (Unity.Entities.SystemState& state) (at Assets/Samples/NetCube/MoveCubeSystem.cs:27)
    MoveCubeSystem+__codegen__OnUpdate_00000023$BurstDirectCall.Invoke (System.IntPtr self, System.IntPtr state) (at <71f6d926c6fc4cafada438bd6cab0a2e>:0)
    MoveCubeSystem.__codegen__OnUpdate (System.IntPtr self, System.IntPtr state) (at <71f6d926c6fc4cafada438bd6cab0a2e>:0)
    (wrapper native-to-managed) MoveCubeSystem.__codegen__OnUpdate(intptr,intptr)
    Unity.Entities.SystemBaseRegistry.ForwardToManaged (System.IntPtr delegateIntPtr, Unity.Entities.SystemState* systemState, System.Void* systemPointer) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBaseRegistry.cs:363)
    Unity.Entities.SystemBaseRegistry.CallOnUpdate (Unity.Entities.UnmanagedComponentSystemDelegates& delegates, Unity.Entities.SystemState* systemState) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBaseRegistry.cs:355)
    Unity.Entities.WorldUnmanagedImpl+UnmanagedUpdate_00001487$BurstDirectCall.Invoke (System.Void* pSystemState) (at <756a6148099440b0b3605856f0cefd02>:0)
    Unity.Entities.WorldUnmanagedImpl.UnmanagedUpdate (System.Void* pSystemState) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/WorldUnmanaged.cs:801)
    Unity.Entities.WorldUnmanagedImpl.UpdateSystem (Unity.Entities.SystemHandle sh) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/WorldUnmanaged.cs:885)
    Unity.Entities.ComponentSystemGroup.UpdateAllSystems () (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:664)
    UnityEngine.Debug:LogException(Exception)
    Unity.Debug:LogException(Exception) (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/Stubs/Unity/Debug.cs:19)
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:675)
    Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:634)
    Unity.Entities.SystemBase:Update() (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBase.cs:406)
    Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:670)
    Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ComponentSystemGroup.cs:634)
    Unity.Entities.SystemBase:Update() (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/SystemBase.cs:406)
    Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@1.0.0-exp.8/Unity.Entities/ScriptBehaviourUpdateOrder.cs:526)
     
  6. jonathan-hertz

    jonathan-hertz

    Unity Technologies

    Joined:
    Jan 15, 2020
    Posts:
    11
    Hi, I looked into the issue, and the problem is that the query in MoveCubeSystem matches all entities with
    Translation
    and
    PredictedGhostComponent
    . When you prespawn a ghost, this ghost will also have the PredictedGhostComponent on the server, which is why your query is also matching that. In the samples for 0.51, we also have the CubeInput as part of the query to make sure that it only matches the cube. You should narrow your query by either adding
    .WithAll<CubeInput>()
    or some other component to narrow it down.
     
    optimise likes this.
  7. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Oops. Didn't notice that. Btw how about another same copy for each ghost? Is that known issue at 1.0.0-exp.8?
     
  8. jonathan-hertz

    jonathan-hertz

    Unity Technologies

    Joined:
    Jan 15, 2020
    Posts:
    11
    Yes, this is a known issue that we are working on a fix for.
     
    optimise likes this.
  9. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    @CMarastoni Can u point me which part of code to hotfix first? Currently I keep blocked by this bug and can't progress my project anymore. I can't really wait for next official release for too long.
     
  10. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    894
    In 1.0-exp is normal: each predicted ghost has two copies: 1 one used for spawning the entity when received in a snapshot, 1 for spawning the entity used for predicted spawning.
    You don't need to care about that detail in general, when you have spawner in your game, the entity can be used for spawning the ghost as usual, and on both client and server.