Improbable Icon

SpatialOS Forums

Toggling player states correctly

Hi all,
I am trying to make players in the FPS unity template project invisible when not moving, and visible when moving. Currently I just crudely set all players child objects to inactive.

My understanding thus far is that player-clients should have “authority” over the actions of a player, but I’m also concerned about hacks regarding the state of the player being handled in the client.

There is a value available in components both on the gamelogic object and client object at runtime, “HasMovementLeft” that would seem to be a good boolean for toggling between the two visible / invisible states. Should I read from the server-worker to update the visual state of the player in the client? Or directly read from the client player game object? Or perhaps maintain an array of player state for every client to read from at the same time?

There are probably entire concepts I am missing here so thank you for helping me

Hi @z-memory

The answer to this question is really dependent on what exactly you’re trying to achieve and how concerned you are about security.

For a simple implementation you should be perfectly fine reading from the local client as it is having all that data sent to it from the worker anyway. The result of this would be that your local client knows where those other players are though, even if they’re hidden from the player, and that does leave the game open to potential cheating. The interesting thing in this scenario is that even if you were reading from the server worker you would still have this same problem.

A better solution to something like this would be to use QBI to filter the invisible entities so that the local client never even receives updates on them until they become visible again. This would entail quite a bit more complexity, however.

If you’re new to SpatialOS I wouldn’t recommend jumping straight into QBI until you’re familiar with the fundamentals. If you want to read up on it though, you can find the docs on it here.

Thanks very much, thats a great point about the server worker existing in basically the same space.

I will just focus on prototyping and learning the basics for now then, thanks!