Tracker (for the Treasure Hunter)

This package allows to track one or multiple entities in the world based on audio signals. This can obviously be used to locate a treasure somewhere in your world. But you can also use it for orientation in games, especially if your game targets people with visual disabilities.

This package was created by Daystiny for the 2022 Crayta Build Jam “Treasure Hunt”

To get started, add the trackerPlayerTemplate to the Player Template. It will add a “Tracker” folder to the Player containing the trackerPlayerScript with a predefined configuration.

There is a trackerDemo template you can drop into your world to get you started.
Walk into the green square to switch on the tracking signals.
Walk into the red square to switch them off.
To make testing easier, the three trackable items are markend with voxels on the floor below them.

Package Configuration

You can configure the properties of the trackerPlayerScript; however, these are only default values.
You can configure the properties individually for each tracked item with a trackerEntityScript.

To quickstart trying the Tracker, you can set the item property on the trackerPlayerScript. This will add the tracking signal to the configured item and the moment any player is in range, they will hear the signal.
This property is only available for trackerPlayerScript; the other properties below are also available for entities with the trackerEntityScript.

  • range: the maximum detection range in centimeters.
  • constant: When checked, this property determines, if the tracking signal is always there as long as the player is in range. When unchecked, the tracking signal can only be heard, while the player is getting closer to the tracked entity.
  • mode: in linear mode, the tracking signal is enhanced (volume und frequency) in relation to the distance to the entity. In logarithmic mode, it is more enhanced on the outer ranges of the distance, while in exponent mode it is more enhanced on the inner ranges.
  • sound: here you configure the sound asset that will determin the tracking signal
  • soundDuration: this determines the frequency in which the tracking sounds are broadcasted, e.g. 0.5 means every half second
  • sound3D: depending on the game you can configure, whether the tracking sound is played from the location of the tracked entity. Otherwise 2D audio is used and you have to rely only on volume and frequency to find the tracked item.

The trackerEntityScript has one additional property: autostart. If you check it, the tracking signal for this entity will start immediately once a player enters the world or gets in range.

Package API:

Standard Functions to connect with Crayta events:

function TrackerPlayerScript:TrackAll(fromEntity)
This function starts the tracking signal for all entities with trackerEntityScript that do not have autostart configured. You can use it to connect to standard entity events like OnTriggerEnter, OnCollision or OnInteract. You can also use it for the Crayta inventory system OnHeld event, if you want the tracker to be an equip-able entity.

function TrackerPlayerScript:UntrackAll(fromEntity)
This function stops the tracking signal for all currently tracked entities. You can use it to connect to standard entity events like OnTriggerEnter, OnCollision or OnInteract. You can also use it for the OnDestroy event, if you want the tracker to stop if it is unequipped.

Functions to use in your own .lua code:

function TrackerPlayerScript:StartTracking(entity, params)

Calling Player:SendToScripts(“StartTracking”,entity, params) will start a tracker for the given entity.
Params is a table with individual settings for this tracker. If it is empty, the default values of trackerPlayerScript will be used.
Notice: you do not need to have a trackerEntityScript on the entity you call this function for, you can either use the default values or define them using code.

function TrackerPlayerScript:StopTracking(entity)
Calling Player:SendToScripts(“StopTracking”,entity) will stop the tracker for the given entity.

Using this Package

You could add audio tracking signals to your world to enhance gameplay or improve accessibility. You could create items with the inventory package that represent the tracker physically and work only when you equip them. You could make team based games in a dark environment where players locate each other using audio only.

Have fun using the package and if you have any questions, contact me by tagging me in the Crayta discord, by email using or using twitter @DaystinyGames

1 Like