The Quantum Golf Sample also provides a number a scripts to facilitate smooth gameplay interaction and viewing in Unity.
CameraController handles the main camera movement. It has a
Transform which is represents the position and rotation values the actual camera is lerping towards. The
_target it follows is the GameObject with an
EntityPrefabRoot component the camera is currently looking at; this GameObject reference is updated automatically when the
Active entity of the global
CurrentTurn is updated.
The controller reads player inputs to pan, tilt and zoom the camera.
Relative Position: the position of the camera relative to the target entity;
Relative Rotation: the amount of rotation added to the camera after it is positioned at the relative position and is looking at target entity;
Follow Target: determines if camera will follow the target entity when it is moving;
Lerp velocity: step factor used when lerping the actual camera towards the dummy transform;
Zoom Sensitivity: scale factor used when zooming in and out on the target entity;
Closest Distance: closest distance allowed when zooming in on the target entity;
Farthest Distance: farthest distance allowed when zooming out on the target entity;
Rotation Sensitivity: scale factor used when player is panning or tilting the camera;
Invert Rotation: mouse drag values are inverted before panning or tilting the camera;
Target clickable area radius: circle radius around target entity where it’s considered as clicking on it.
UITurnClock script is responsible for polling the global
CurrentTurns remaining turn duration from simulation when the
CurrentTurn uses a timer and update the time displayed on the central clock panel.
FairTimer script presents a pattern for displaying a more fair timer to the local player than a more realistic timer would. It takes into consideration the client’s RTT and/or its Input Offset.
N.B.: This does not interfere with anything on the simulation side. The current turn timer runs synced in every client, it is just the value displayed to the player that is changed proportionally to their lag. This is a configurable and optional feature and should be tweaked to reach the desired behaviour.
FairTimer solution presented in the Quantum Golf Sample is gameplay agnostic and can be used in any timer based turn-based game with minor changes.
UIStartCountdown script handles the visual timer countdown display at the center of the screen before the first turn begins.
UIPlayerView is responsible for polling
TurnData information for a given player and enabling / disabling / updating visual elements accordlingly. This includes:
- increasing the turn
Numberwhen a player's turn has ended
- changing the status text when a player’s status changes
- making the skip button non-interactable when turn is inactive or the player is not local
- updating player’s fillable ring timer
UIScore script is responsible for enabling a score panel with the players’ scores info when a
GameplayEnded event is raised by the simulation.