Skip to main content

Using Traits

Developers will be able to read and write a user's Traits inside an Experience.

Trait Decay

Trait values will decay over time. This is to incentivize the user to return more frequently to the app so their Trait profile stays up to date.

The exact value of Traits cannot be accessed. It is recommended to use other Traits, preferably the opposite Trait, as a comparison for a particular Trait.

Example

If a user is more Cautious than Impulsive, then the game could allow more strategic paths to complete a level. If the opposite is true, then the game could be catered for more fast paced players.

Traits API

note

The term "active" Traits is used in the Traits SDK API to refer to all current Traits actively supported by the Genies SDK.

Traits SDK Methods

To read and write to a user's Traits it is required to use the TraitsSdk library methods:

import { TraitsSdk } from "Genies.Traits.Api";

TraitsSdk.GetActiveTraits()
TraitsSdk.GetActiveTraitsByArchetype()
TraitsSdk.GetArchetypeIdFromTraitId()
TraitsSdk.GetArchetypeNameFromArchetypeId()
TraitsSdk.GetListOfTraitsFromArchetypeId()
TraitsSdk.GetSortedListOfGivenArchetypeIds()
TraitsSdk.GetSortedListOfGivenTraitIds()
TraitsSdk.GetStrongestXArchetypeIds()
TraitsSdk.GetStrongestXTraits()
TraitsSdk.GetTraitCategoryFromTraitId()
TraitsSdk.GetTraitListFromTraitCategory()
TraitsSdk.GetTraitNameFromTraitId()
TraitsSdk.GetWeakestXArchetypeIds()
TraitsSdk.GetWeakestXTraits()
TraitsSdk.UpdateTraitsFromExperience()
tip

Read the TypeScript API page for more information on Trait SDK methods.

Trait Class

Once a Trait is read, it returns an object of type Trait with the following properties:

import { Trait } from "Genies.SDKServices.Model";

let trait: Trait;

trait.ArchetypeColor
trait.ArchetypeId
trait.ArchetypeName
trait.Description
trait.Id
trait.Name
trait.OppositeArchetypeId
trait.OppositeTraitId

TraitExperienceStrength Enum

When writing to a user's Trait, it is required to use a TraitExperienceStrength enum value to describe the amount to change. Here are the three possible values:

import { TraitExperienceStrength } from "Genies.Traits.Api";

TraitExperienceStrength.SMALL
TraitExperienceStrength.MEDIUM
TraitExperienceStrength.LARGE
note

TraitExperienceStrength can only be a positive value which means the only way to decrease a Trait is to increase its opposite Trait.

TypeEnum

When reading a Trait's category, it is return as a TypeEnum enum value. Here are the possible values:

import { TypeEnum } from "Genies.SDKServices.Model.Trait";

TypeEnum.EXPRESSIVE;
TypeEnum.MINDFUL;
TypeEnum.EMOTIONAL;
TypeEnum.SOCIAL;

TypeScript Example

Reading Traits

Here is an example of reading a user's top 3 Traits and displaying all of their properties:

import { MonoBehaviour } from "UnityEngine";
import { GeniesSdk } from "Genies.Components.SDK.Core";
import { TraitsSdk } from "Genies.Traits.Api";
import { Trait } from "Genies.SDKServices.Model";
import { List$1 } from "System.Collections.Generic";

export default class MyScript extends MonoBehaviour {
async Start() {
await GeniesSdk.Initialize();
//Get the top 3 Traits
TraitsSdk.GetStrongestXTraits(3, this.OnSuccess, this.OnFailure);
}

OnSuccess(response: List$1<Trait>) {
console.log("These are the user's top 3 Traits:");
//Print each Trait's properties
response.ForEach((trait: Trait) => {
let str: string = "-------------------------";
str += "\nTrait Name: " + trait.Name;
str += "\nTrait ID: " + trait.Id;
str += "\nTrait Description: " + trait.Description;
str += "\nArchetype Name: " + trait.ArchetypeName;
str += "\nArchetype ID: " + trait.ArchetypeId;
str += "\nArchetype Color: " + trait.ArchetypeColor;
str += "\nOpposite Trait ID: " + trait.OppositeTraitId;
str += "\nOpposite Archetype ID: " + trait.OppositeArchetypeId;
console.log(str);
});
}

OnFailure() {
console.log("ERROR: Could not read the user's top 3 Traits!")
}
}

Writing Traits

Here is an example of increasing the user's Impulsive Trait by a large amount.

import { MonoBehaviour } from "UnityEngine";
import { GeniesSdk } from "Genies.Components.SDK.Core";
import { TraitsSdk, TraitExperienceStrength } from "Genies.Traits.Api";
import { List$1 } from "System.Collections.Generic";

export default class MyScript extends MonoBehaviour {

private impulsiveTraitId: string = "20295e77-7468-4960-aa7d-77bf824dbbfb";
private traitIds = new List$1<string>();

async Start() {
await GeniesSdk.Initialize();
this.traitIds.Add(this.impulsiveTraitId);
//Increase the Impulsive Trait by a large amount
TraitsSdk.UpdateTraitsFromExperience(
TraitExperienceStrength.LARGE,
this.traitIds,
this.OnSuccess,
this.OnFailure
);
}

OnSuccess() {
console.log("Impulsive Trait was increased!")
}

OnFailure() {
console.log("ERROR: Impulsive Trait was NOT able to be increased!")
}
}