Vixen
02b45cc4
csharp
public sealed class LocalPlayerSystem

Notices which of the bodies this client owns is the one it drives.

Read the guide page for this →

As a system

Phase
EarlyUpdate

Remarks

The client's half of PlayerSpawner. A client is told about a spawn through NetworkSpawn, which carries the owner; a PlayerPawn tag rides on the prefab, so it is present the moment NetworkSpawnSystem builds the instance. An entity carrying both, owned by this connection and possessed by nothing, is this player's body — and that inference costs no wire bytes and no second message.

Why an inference rather than an RPC saying "you are pawn 47". A message can arrive before the spawn it names, after the pawn has been destroyed, or twice; every one of those is a case somebody has to write. A query over state that is already replicated has none of them, because it is re-evaluated every frame and is right whenever it runs.

It does not create the controller. A client's controller exists from the moment it has a PlayerId — before any pawn, and still there after one dies — which is the whole point of the controller being separate.

Fields and properties (4)

  • public SystemAccess Access
  • public PlayerId Local

    Which connection this machine is.

  • public Entity Controller

    The controller this machine's player drives with.

  • public long AdoptedCount

    How many pawns this has taken charge of.

Methods (2)

  • public override JobHandle Update(in SystemContext context, JobHandle dependency)

    Runs the system.

  • public int Adopt(World world)

    Possesses any owned, unpossessed player pawn with the local controller.

Used by (1)

  • LocalPlayerSystemTestsVixen.Net.Engine.Tests