dot big bang

Developer API
Menu
All
  • Public
  • Public/Protected
  • All

Collectable Properties

The simplest form of save data is tracking how many of an object the Player has collected. Drop a Collectable script onto an Entity and fill in the properties to easily add them to your game.

Collectables will behave differently based on if they are networked or not. To make a Collectable networked just add the networked tag to it.

  • Networked - The Collectable can be collected by a single Player. When collected it will vanish on all Players screens and reset after the reset time has passed if configured to do so.

  • Not Networked - Each Player can collect it without affecting other Players. It will reset after the reset time has passed based on when that Player collected it.

Next I’ll go over each property on the Collectable script and explain what it does.

  • Data Id - This is used as an identifier for the save data. It should be unique per Collectable type and helps the system understand what it is counting when this is collected.

  • Amount - The amount of this Collectable type that gets added to the Players data when this is collected. You can use this to make a single coin, or a bundle of 10 experience.

  • Reset Seconds - If this is greater than 0, after this has been collected it will appear and be collectable again once this amount of seconds has passed.

  • Collect Fx - This template will be spawned at the same location as the Collectable when it is collected. Make sure you add a script to the template that destroys it after a set amount of time so you don’t end up with a lot of Entities in your game.

  • Floating Text - If you have a “Floating Text Manager” in your game, this text will appear at the location of the Collectable when it is collected. The next several settings let you modify the position and appearance of the text.

You can also use special formatting tags to inject information dynamically. Anything inside curly braces will be swapped for an actual value if it exists. These values need to match property names on the Collectable script, or if you are using a Database, the Collectable Data script that matches the “Data Id”.

In the example image you can see that {amount} and {displayName} will get swapped for “1” and “Stone Key”.

  • Floating Text Color - The color of the floating text.

  • Floating Text Opacity - The transparency of the floating text. 0 = invisible, 1 = fully opaque.

  • Floating Text Scale - The size of the floating text.

  • Floating Text Offset - Use this to move the position of the floating text relative to this Collectable. This is useful if you want the text to appear higher up in the air, or off to one side.

While Collectables work on their own without any additional setup, if you want to use Collectables with the other systems, like UI or Collectable Containers, you will need to add them to a Database.