Skip to content

Create Traits Using ScriptableObjects

Shi Johnson-Bey edited this page Feb 28, 2024 · 3 revisions

How to create traits using ScriptableObjects

Users can create new traits using Unity ScriptableObjects. TDRS makes this easy, by providing an entry in the "create" menu.

  1. Right-click in the Project window and select Create > TDRS > Trait.
  2. Name the trait whatever you wish
  3. Fill in the fields
  4. Add the trait to the Traits list on your SocialEngineController instance.
  5. Now the trait is available to use in base configurations and social events.

Below are explanations of each of the fields:

  • Trait ID: (Required) A unique identifier for this trait to differentiate it from other traits. By convention, the name should be all lowercase with underscores instead of spaces, and no punctuation.
  • Trait Type: Specifies if the trait is to used with agents or relationships.
  • Display Name: (Required) A regular text name to be displayed in GUIs. This can contain spaces, capitalization, and punctuation.
  • Description: A short text description provided to explain why the agent/relationship has the trait. You can use the [owner] value in your description to have the owner of an agent trait's UID inserted into the description. If the trait is a relationship trait, the [target] template value is also available.
  • Modifiers: A list of modifiers to apply to the agent/relationship the trait is attached to.
    • Stat Name: The name of the stat to apply the modifier to
    • Value: The value to apply to the stat
    • Modifier Type: How should the value be applied to the stat.
      • FLAT: Add the Value to the stats base value
      • PERCENT_ADD: Treat the Value as a percentage where (1.0 is 100%) and increase the base stat value by the sum of all calculated modifiers with type PERCENT_ADD. See Stats for an example of how this is calculated.
      • PERCENT_MULTIPLY: Treat the Value as a percentage where (1.0 is 100%) and increase the base stat value by the given percentage. See Stats for an example of how this is calculated.
  • Conflicting Traits: A list of Trait IDs of traits this trait cannot coexist with on the same agent/relationship.

Example Trait Definition

Screenshot of trait ScriptableObject