Use cloud code to create game logic server side

Good morning, I'm here to ask for your advice.
I'm developing a video game based on a persistent world. Let's assume we have 2 cities 2 hours apart and that the path from city X to city Y is a numbered route.
The path would be [City X - 1 - 2 - 6 - 7 - 8 - City Y], so when the player moves on the map, the server should calculate the movement being made and which points the player passes through.
This is needed on the server side because events can happen at each node of the road, so it's important to understand at which point of the path the player is.
The question is: how do I move the player on the server side without client intervention?
For example, Google offers Cloud Task to manage large quantities of queues, but I'm not sure what I can use on Cloud Code.. isn't there a server-side event queue?

Thank you.

1 Like

Hi DorexGames,

how do I move the player on the server side without client intervention?

We have a section here on Cloud Code server authority https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/server-authority that will give a better overview but as Cloud Code is stateless, the state of the user/ world movement would need to be provided either through the function parameters or via a intermediary storage solution such as Cloud Save https://docs.unity.com/ugs/en-us/manual/cloud-save/manual additionally some mechanism would need to invoke the cloud code function when the player has made their move.

Cloud Code provides a way to hook into some UGS events via the Triggers service: https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/triggers so there could be potential to use Cloud Save to provide the server-side event queue/ or event which triggers a cloud code function whenever a particular key is updated (see below for examples)
- https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/triggers/concepts/filters
- https://docs.unity.com/ugs/en-us/manual/cloud-code/manual/triggers/tutorials/use-cases/tune-game-difficulty#Tune_game_difficulty_level

I hope that is of some help but let me know if Cloud Code doesn't fit your use case so I can feed it back to the team.

1 Like