This is me showcasing a few basic mechanics mechanics using SpatialOS and Unity.
The blank SpatialOS started project was used as a boilerplate (so the Unity project itself is in workers/unity).
Space - jump
Space while in the air - smash
The player character uses an Animator
-based state machine (for the delayed jump animation) that's synched via a SpatialOS component.
Implemented in Assets/Scripts/Entities/PlayerStateMachine.cs and Assets/Scripts/Input/PlayerMovementControl.cs
The player character gradually rotates towards the requested movement direction, meanwhile moving foward in the direction it's facing now, akin to a car.
Implemented in Assets/Scripts/Input/PlayerMovementControl.cs
Shapeshifting objects are spawned at random locations with random delays after the server's start. They drift around within the bounds specified on spawn.
Implemented in Assets/Scripts/Systems/ShapeshifterSpawnSystem.cs
A networked game should be able to authentice the connecting player and load their data from some external store, but by default the PlayerLifecycle
creates a player object without any external input - meaning it doens't support an async
form of the CreatePlayerEntityTemplate
delegate. So i've made a modified AsyncHandleCreatePlayerRequestSystem
(Assets/Scripts/Systems/AsyncHandleCreatePlayerRequestSystem.cs) and unpacked the part linking it (Assets/Scripts/Workers/UnityGameLogicConnector.cs). It sends a dummy SessionKey
parameter which in read in the CreatePlayerEntityTemplate
server-side method.
Note: for stability, the whole PlayerLifecycle
should be unpacked, in case some update will change parts outside the modified System.
URP doesn't seem to support partial modifications to it's vertex/fragment shader parts, so i've re-stitched parts of the original Lit
shader and modified the vertex part to smoothly morph an object between it's original shape and the sphere (Assets/Shaders/Entities/MorphingLit.shader).
Note: in case multiple different modifications of the standard URP shader will be required, it might make sense to refactor the unpacked code into a more combinable set of blocks.