Tracked Values

The game mood can be directly linked to any game values. This allows the music or atmosphere to react dynamically to the current game status.

The following example demonstrates how the player experience (health) is linked to the mood system.


Example: Tracking Player Health #

var healthTracking = new Tracking<float>(
    this,
    () => health,
    new Vector2(0, 100),
    new MoodVector(3f, 3f, 3f, 3f, 0),
    invert: true
);

Musician.Runtime.Musician.AddTracking(healthTracking);

Explanation of the individual code components #

new Tracking<float>(...) #

Creates a new tracking object for a value of type float.


this #

The owner of the tracking.

  • Usually a MonoBehaviour
  • Used to automatically remove tracking when the object is destroyed

() => health #

A getter (lambda function) that returns the current value.

  • Queried regularly by the system
  • Can return any variable or calculation

Example:

() => currentHealth

new Vector2(0, 100) #

The value range within which the tracked value fluctuates.

  • x → Minimum value
  • y → Maximum value

This range is used to normalize the current value.
Example:

  • 0 = empty
  • 100 = full

new MoodVector(3f, 3f, 3f, 3f, 0) #

Defines how strongly this value influences the individual mood axes.

👉 The higher the value, the stronger the influence on the musical mood


invert: true #

Inverts the influence of the value.

  • false (default): high value → strong mood influence
  • true: low value → strong mood influence

In the health example, this means:

  • High health → relaxed mood
  • Low health → tense/dangerous mood

Musician.Runtime.Musician.AddTracking(...)

Registers tracking with the global music/mood system.

⚠️ Important:

  • Without this call, nothing happens
  • Tracking will now be evaluated automatically

What do I need to do to track my own values? #

  1. Define a value (e.g., health, stamina, hunger, danger)
  2. Set an appropriate value range
  3. Decide how strongly the value influences the mood
  4. Optional: activate invert
  5. Register tracking with Musician

Typical use cases #

  • Gaming experience
  • Time pressure
  • Resource scarcity
  • Quest statuses

What are your feelings

Updated on 15. Dezember 2025