[1.0.0-exp.8] Breaking changes questions

  1. Both World.GetExistingSystem().PredictingTick and
    World.GetExistingSystem().ServerTick change to SystemAPI.GetSingleton().ServerTick?

  2. World.GetExistingSystem().Time.DeltaTime change to SystemAPI.Time.DeltaTime?

Hello @optimise ,

Very good question !

Can you please share your manifest.json because i am struggling to migrated from 0.51 to 1.0 with all the dependencies… ?

That is what we used for the migration of our current netcode project and it worked as expected.

Also don’t forget to remove the checks to prediction and instead use the WithAll(typeof(Simulate), which is a lot more pleasant than before.

@Ali_Bakkal You just need to upgrade everything to 1.0, dependencies should be automatically handled. With what are you exactly struggling?

Unity does not offer automatic upgrade, so i change directly the version inside of the manifest.json. And when i put : Entities, replace Hybrid by entites.graphics and Netcode to 1.0, i have dependency errors… can you please send me a copy of your manifest.json in order to check all my dependencies…

Thanks in advance

If you can’t upgrade directly from the package manager it’s probably because you aren’t using the right unity version.

Which unity version are you currently using in the project?

I am using Unity 2020.3.30f1, which version should i use then ?
(which is stable to build on Linux, Macos, Android and iOS)

If you want to use 1.0.x you need to use 2022.2.x (currently in beta).

otherwise you need to stay on 0.53

(if you use netcode you currently can’t build for any platform, it’s a known issue and they are working on it)

Ok Thank you @Occuros for your help !

Not really understand what u mean. Can u show me an example?

There is a full upgrade guide Changelog | Netcode for Entities | 1.0.17

That tell you how to go from 0.51 to 1.0-exp.8.
One missing details, sorry about it, regards the Simulate component.

Systems that run in the prediction loop and there need to update the state of the Predicted ghost (or in general have to deal with ghosts), must add to their queries the WithAll<Simulate>() clause.

For example:

Entities.WithAll<Simulate>().ForEach(.....)...
//or with Idiomatic foreach
foreach(... in SystemAPI.Query<...>().WithAll<Simulate>)

Do u mean when u the system is at PredictedSimulationSystemGroup and you are updating owner predicted/predicted ghost, you need to put WithAll() into the ghost? Btw then do we still need to call predictedghost.ShouldPredict() from PredictedGhostComponent just like at 0.51?

All entities now have an enableable Simulate component tag (by default).

You don’t need to check for the ShouldPredict anymore.
instead, your queries need to check for the presence of the Simulate component. That it.

So before was:

Entities.Foreach(Entity ent, ref MyCompo compo, in PredictedGhostComponent component)=>
{
    if(!PredictedSimulationSystemGroup.ShouldPredict(component))
         return;
})

Now, there is no need to get the PredictedSimulationSystemGroup anymore and the loop become

Entities.WithAll<Simulate>().Foreach(Entity ent, ref MyCompo compo)=>
{
    if(!PredictedSimulationSystemGroup.ShouldPredict(component))
         return;
})

The prediction loop take care of enabling/disabling the simulate tag as necessary during the loop for you.

1 Like

There is also now a different way how you can handle inputs.

No more Tick is required, and events are supported (so you can be sure that jump button gets processed):

public struct PlayerInput : IInputComponentData
{
    public int Horizontal;
    public int Vertical;
    public InputEvent Jump;
}

So it is no more a buffer, but you get the correct input for the frame you are processing in the prediction.

The documentation is a little problematic as it still uses the previous way in the GettingStarted section, and in the Command Stream section, it still uses the deprecated GenerateAuthoringComponent attribute.

But if you use the bakers instead the Command Stream section should be up to date (I think correct @CMarastoni ?)

At least we managed to get our project fully up and running in the editor.

you can still use the old Command Buffer way if you want. If you use the IInputComponentData then you just need to grab the component itself (that is guarantee to have the correct tick information in the prediction loop).
Under the hood everything will be automatically be baked, a command buffer will be added to the entity. But you should not care about it.

I see but currently I have a lot of systems at PredictedSimulationSystemGroup still using predictedGhostComponent.ShouldPredicted(). Can I still keep it first until I have time to upgrade to this new way? Btw if I understand correctly, seems like there’s typo for code snippet. I guess new way should like that right?

Entities.WithAll<Simulate>().Foreach(Entity ent, ref MyCompo compo)=>
{
 
})

Yes probably there was a typo :slight_smile:
You can still use the old way if you wish (it still work) In the end, we use the ShouldPredict method internally.

1 Like

For my old Command Buffer way I put

One more question want to confirm about this. Will this WithAll() without if PredictedSimulationSystemGroup.ShouldPredict(component) check still working properly if it’s query the child ghost entity of owner predicted/predicted ghost? This child ghost entity is part of the owner predicted/predicted ghost that is child of it that u can fold/unfold at Entities Hierarchy window. From what I see child ghost entity also have Simulate tag component.

Yes, the simulate tag will be updated on all entities in the LinkedEntityGroup of the ghost, so everything in the ghost prefab will be updated.
It will not work for transform hierarchies which are not using the same LinkedEntityGroup though - and I am not sure if the Hierarchy window shows linked entity groups of transform hierarchies so I don’t know if checking there is the right way to see if it will be updated.

1 Like