#Processing player input in `ISystem` - with remote player prediction

1 messages · Page 1 of 1 (latest)

bronze wagon
#

I have a component that looks like this:

    [GhostComponent(PrefabType = GhostPrefabType.AllPredicted, OwnerSendType = SendToOwnerType.SendToNonOwner)]
    public struct PlayerInput : ICommandData
    {
        [GhostField] public NetworkTick Tick {get; set;}
        [GhostField(Quantization = 0)] public float3 MoveVector;
    }

How do I process this input in an ISystem? The docs show how its done in SystemBase here: https://docs.unity3d.com/Packages/com.unity.netcode@1.3/manual/prediction.html#remote-player-prediction

But Entities.ForEach is not available in ISystem. So how can I get the player input at the current tick, and simulate player movement?

dusk osprey
#

EFE shouldn't be used at all anymore, it will be removed in 2.0

#

Just use IJobEntity or SystemAPI.Query as a replacement

#

Both are well documented in the entities manual

neat thunder
#

Yeah what tertle said (thanks mate), and apologies, we need to update the manual code at some point.

Relatedly: ICommandData is the older way of doing inputs, for 1.x onwards we recommend IInputComponentData, which means you can typically just:

  1. Write to this component on your entity marked as GhostOwnerIsLocal in your GhostInputSystemGroup (added in 1.2.x) system.
  2. Read from this on your server and client predicted system. You can optionally fetch the entire buffer too, if needed.

Comprehensive example here: https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/NetcodeSamples/Assets/Samples/HelloNetcode/2_Intermediate/02_PredictedSpawning/ProcessFireCommandsSystem.cs#L45

GitHub

Contribute to Unity-Technologies/EntityComponentSystemSamples development by creating an account on GitHub.