Search Unity

Resolved [Case 1211673] GhostPrefabBuffer Cube Processed in BuildPhysicsWorld

Discussion in 'Physics for ECS' started by florianhanke, Jan 15, 2020.

  1. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    While trying to reproduce https://forum.unity.com/threads/0-2...not-pick-up-physicsvelocity-component.809211/ in a minimal case, I noticed that BuildPhysicsWorld processes two cubes when I put one in the Convert To Client Server Entity.

    The project is a fresh URP project with NetCode and Unity Physics installed. In the scene, there is a Networking (Convert To Client Server Entity), and a Cube and GhostCollection as children. The cube has a Ghost Authoring Component and the GhostCollection has it in its list.

    Here is the cube:

    cube-with.components.png

    I expected there to be only one cube in the Server World as a result, but:

    all-entities-with-two-cubes.png

    The first cube (2) is probably the cube that is sitting in the GhostPrefabBuffer. This one is also processed by the BuildPhysicsWorld system:

    BuildPhysicsWorld.png

    I assume cube (2) should not be processed by the BuildPhysicsWorld system, and only the one that is actually "in the world" (not in the GhostPrefabBuffer) should be processed, e.g. falling down etc. By the looks of it, however, both are processed by the BuildPhysicsWorld system.

    One thing I am wondering about: Should the GhostPrefabBuffer etc. be in another world and only when prefabs are spawned into the Server World should it be used to spawn new entities into the Server World?

    Many thanks in advance!
     
  2. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    The GhostCollection should be in the same world. One of the Cubes created - usually the first one - should have a prefab tag added to it which prevents it from being processed by any systems. Not sure why that is not happening in your case and I was not able to reproduce it.
    Did you make the Cube a prefab or just add it to the scene? All ghosts should be prefabs.
    What does the Cube with the prefab tag on it look like, is it processed by many systems or just BuildPhysicsWorld?
     
    florianhanke likes this.
  3. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Thanks for the answer – just a quick question (so I can try anwering your questions hopefully tonight): Did you try it with the case-attached project to reproduce or did you try to recreate it manually? From my first picture, it looks like it may not be a Prefab…?
     
    Last edited: Jan 20, 2020
  4. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    I tried to reproduce it manually, I only saw the forum thread - not the case - so I didn't know there was an attached project
     
  5. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Thanks – in that case, I may have accidentally used a non-prefab cube (otherwise you'd have seen it). Will mark as resolved if that is the case.
     
  6. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Ok, I have checked my project attached to case 1211673 – indeed, the cube is not a prefab.

    I've now made it a prefab, and only one is now picked up (the one with the GhostSystemStateComponent). So your hunch was right, thanks!

    To get it working after changing the cube to a prefab, updating the ghost list was necessary (pretty obvious, but not that obvious – the original cube instance was still in there).

    I think it would be helpful if adding non-Prefabs/non-Ghost-Authoring-Components to the Ghost Collection Authoring Component was not allowed, if that is possible.
     
  7. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    Good, thanks for checking.

    Yes, we still have work to do on making sure invalid setups gives errors instead of mysterious bugs in the netcode. I have filed an internal bug for this one so we don't forget it.
     
    Adam-Mechtley and florianhanke like this.
  8. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Excellent, thanks!