This document is about: QUANTUM 2
SWITCH TO

Assets

Quantum Assets are a feature for defining data-driven containers that end up as immutable instances inside an indexed database.

ConfigAssets

The ConfigAssets asset holds a reference to all other configuration assets necessary to configure the game at start up. It is used to centralize the configuration of the initialization assets in Unity and serializing them in Quantum. It also simplifies the process of adding new types and/or instances of data assets to the game.

To add a new custom data asset ConfigAssets, simply add a public field of type AssetRefYourNewAsset to ConfigAssets.cs; build the project and drag the custom asset instance to the matching field on the ConfigAssets instance in Unity.

C#

public partial class ConfigAssets
{
  public AssetRefGameConfig GameConfig;
  public AssetRefTurnConfig StartCountdownConfig;
  public AssetRefTurnConfig PlayTurnConfig;
  public AssetRefTurnConfig CountdownTurnConfig;
}

It ConfigAssets used to initialize the game is serialized in RuntimeConfig.User.cs.

C#

partial class RuntimeConfig {
  public AssetRefConfigAssets ConfigAssets;
  public Boolean IsLoadedGame;

  partial void SerializeUserData(BitStream stream)
  {
    stream.Serialize(ref ConfigAssets.Id);
    stream.Serialize(ref IsLoadedGame);
  }
}

On the Unity side, an instance of this data asset is link with the QuantumRunnerLocalDebug script to enable playing in local debug mode.

configs

The UIRoom script holds a reference to the asset for playing in online mode.

C#

var config = RuntimeConfigContainer != null ? RuntimeConfig.FromByteArray(RuntimeConfig.ToByteArray(RuntimeConfigContainer.Config)) : new RuntimeConfig();
config.ConfigAssets.Id = ConfigAssets.Id;

GameConfig

The GameConfig asset holds general purpose values for the simulation.

  • MaxStrokes: Used by the GameEnd sytem to decide if the player still has any strokes left.
  • SpawnBallsNearHole: Used by the SpawnSystem to determine if balls should be spawned on Regular or NearHole type SpawnPoint.
  • Min-Max Strike Angle and Force: Min-max values used by the PlaySystem for clamping a ball strike.
  • ForceBarVelocity: Polled from Unity to update a force bar marking position when a player is aiming.
  • HitHoleVelocityThreshold: The velocity magnitude value below which the ball is considered as hitting a hole when triggering a hole collider;
  • HoleBumpForce: A vertical force added to a ball when it hits a hole with a velocity magnitude higher than the HitHoleVelocityThreshold;
  • Hole Trigger and Rough Field Layers: String fields for the physics layer names in Unity for the Hole Trigger and Rough Field respectively. Used by the Play System for detecting those layers when a balls hits a static collider.

C#

public partial class GameConfig {
    public Int32 MaxStrokes;
    public Boolean SpawnBallsNearHole;
    public Int32 MinStrikeAngle;
    public Int32 MaxStrikeAngle;
    public Int32 MinStrikeForce;
    public Int32 MaxStrikeForce;
    public Int32 ForceBarVelocity;
    public Int32 HitHoleVelocityThreshold; 
    public Int32 HoleBumpForce;
    public string HoleTriggerLayer;
    public string RoughFieldLayer;
}

TurnConfig

The Quantum Golf Sample uses a TurnConfig asset to define the core attributes of a turn.

  • UsesTimer: the global variable Ticks is increased every frame as long as the turn's status is Active.
  • TurnDurationInTicks: the maximum length of a turn in ticks.
  • IsSkippable: defines whether a player can skip their own turn.

C#

public partial class TurnConfig
{
  public Boolean UsesTimer;
  public Int32 TurnDurationInTicks;
  public Boolean IsSkippable;
}

More configurable data can and should be added to tailor the turn configuration to match your specific design requirements.

BallSpec

The BallSpec asset holds data related to the Ball.

  • EndOfMovementVelocityThreshold: A velocity magnitude value above which the ball is still considered as moving.
  • EndOfMovementWaitingInTicks: The amount of ticks the PlaySystem waits after the ball has stopped moving until it declares the end of a turn.

C#

partial class BallSpec
{
  public FP EndOfMovementVelocityThreshold;
  public Int32 EndOfMovementWaitingInTicks;
}
Back to top