Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Netcode 0.5.0-preview.5 'Cannot convert a owner predicted ghost 'prefabName' as a scene instance

Discussion in 'NetCode for ECS' started by doingTheCodes, Dec 12, 2020.

  1. doingTheCodes

    doingTheCodes

    Joined:
    Apr 27, 2016
    Posts:
    19
    Hi all.

    following the tutorial on https://docs.unity3d.com/Packages/com.unity.netcode@0.5/manual/getting-started.html

    When trying to setup the cubePrefab I see the error upload_2020-12-12_15-9-10.png

    This is because the 'sharedData' container object has the 'Convert To Client Server Entity' property 'Conversion Target' set to a non [Server] value

    An area of confusion is that the 'Convert To Client Server Entity' is marked as obsolete
    upload_2020-12-12_15-19-1.png
    which suggests that there may be some transition from this class to the 'Convert to Entity' class.

    I also have some serious confusion about the 'sharedData' object. It's instructed as created as an empty object, BUT it's later referred to as a scene.

    This even further suggests that the current way to do networking is to use a subscene workflow (please comment a tutorial if you have one) and the 'Convert to Entity' class should be attached to it BUT it still causes this error in the title and listed above.

    If anyone understands this and can help me know what to do please share.
     
  2. doingTheCodes

    doingTheCodes

    Joined:
    Apr 27, 2016
    Posts:
    19
  3. Krooq

    Krooq

    Joined:
    Jan 30, 2013
    Posts:
    194
    I currently have the same confusion with the tutorial.
    I wish there was a better way to keep the docs up to date as these things develop but I understand the situation and honestly its just nice to be involved.

    Thanks for the tip @doingTheCodes :)
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    882
    Unfortunately docs hasn't been update for 0.6-preview.7.
    We already have the docs up-to-date using the sub-scene workflow but they aren't available yet (for a number of reason, big one is the many changes in code-gen and authoring).
    The use of ConvertEntityClientServer has been depreciated while ago and all of our samples use sub-scenes now.
     
    Occuros and Krooq like this.
  5. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,114
    @CMarastoni Can u tell me more about sub-scene workflow? Is that next Netcode version has even better sub-scene workflow that able to decide specific sub-scene to client world or server world only? Like I want sub-scene A to client world and sub-scene B to server world and also the build pipeline will smartly build sub-scene A only into client build and sub-scene B only into server build.
     
  6. desertGhost_

    desertGhost_

    Joined:
    Apr 12, 2018
    Posts:
    259
    I would also like this to be a feature.
     
  7. Krooq

    Krooq

    Joined:
    Jan 30, 2013
    Posts:
    194
    Thanks for clarifying @CMarastoni!
    No stress on the docs mate, the DOTS teams are doing an amazing job. It's a difficult task to keep documentation up to date with a rapidly evolving solution.

    @optimise perhaps best to create a new thread? This one is 7 months old and I'd like to see discussion on your topic. Particularly interested in your use case.
     
  8. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    882
    There are plans to add exactly that kind of supports. I don't have a specific roadmap date to share at the moment, but it is definitely planned.
     
    desertGhost_ and optimise like this.
  9. Migaroez

    Migaroez

    Joined:
    Jun 16, 2014
    Posts:
    3
    Does anyone have a clean update example on how to get this to work? I'm a bit lost
     
    bb8_1 likes this.
  10. bb8_1

    bb8_1

    Joined:
    Jan 20, 2019
    Posts:
    100
    Ok - I use netcode 0.6 + URP - and all pre subscene-gameobejct-conversion netcode versions worked for me perfectly but conversion with ss doesn't work at all(only in NetCode in Entities it shines). Of non dots packages I use only new Input system. I use HybridRendererV2 - 0.11.0
    also I use unity 2020.3.24

    So basically i created minimal NetCode project :
    1. All cs files from NetCube sample(NetCube sample on github) are the same in my project except that I added just 1 line in OnCreate method of Game.GoInGameClientSystem - as a first line I added : RequireSingletonForUpdate<GhostPrefabCollectionComponent>(); (as suggested by Devs in one post on forum)

    2. I added subscene and to subscene I added GameObject with GhostAuthoringComponentScript(DefaultGhostMode=OwnerPredicted), GhostOwnerAuthoring script and MovableCubeCompoentAuthoring component(from NetCube sample) - then i created prefab of this GO deleted GO and moved instance of prefab as a child of subscene (just in case)

    Now when I close the ss(I'am new to ss so i guess it should be closed before we hit the play button(?)) I see in conversion log of ss(in inspector) error : Exception: InvalidOperationException: Cannot convert a owner predicted ghost raider as a scene instance

    If I start the game nothing happens - it doesn't show any messages except that is HRV2 active - game doesnt react to inputs.

    Here is NetCube sample on github : https://github.com/Unity-Technologies/multiplayer/tree/master/sampleproject/Assets/Samples/NetCube

    So what I am doing wrong here - can someone explain me?Thx in advance
     
    Last edited: Dec 4, 2021
  11. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    This means you have an instance of a ghost as part of the sub-scene. So the ghost will be spawned as part of loading the level. When you do that there is no way to setup who owns the ghost (since the scene conversion happens at build time we do not know what the connection ids will be and who should own it). For that reason we do not support placing owner predicted ghosts as pre-spawned scene instances in a level.

    If this is an object you do want to be placed at authoring time and loaded on all clients you cannot use owner predicted.

    If you need this to be owner predicted it needs to be spawned for a specific player/connection. To do that you need to create a reference to the entity prefab in the subscene and spawn that at runtime. The code you linked still uses the GhostPrefabCollectionAuthoring to get a list of all prefabs, so you can add the new prefab to that list, remove the scene instance of it, and spawn it the same way we do in `GoInGameServerSystem` in Game.cs
     
    bb8_1 likes this.