Mutations Showcase
This room showcases various ways in which Character Mutations can be utilized to modify the properties of Inworld characters at runtime in Unity.
Description and Motivation Mutation
The Description and Motivation Mutation showcase is an example of how you can use Parameters and Character Mutations to modify properties of an Inworld character at runtime.
In this example, the Motivation and Core Description of a character are modified to update their favorite animal.
In the Unity Playground there is a cat and a dog object that the player can select to set the Mutation Innequin's favorite animal.
When an animal is selected the client sends a trigger containing a favorite_animal
parameter to activate the change_favorite_animal
goal.
public void OnCurrentSelectedAnimalChanged(string animalName)
{
if (m_CurrentSelectedAnimal == animalName) return;
m_CurrentSelectedAnimal = animalName;
m_InworldCharacter.SendTrigger("change_favorite_animal", false, new Dictionary<string, string>()
{
{
"favorite_animal",
m_CurrentSelectedAnimal
}
});
...
}
This updates the Mutation Innequin's Motivation and Core Description.
goals:
- name: "change_favorite_animal"
repeatable: true
activation:
trigger: "change_favorite_animal"
actions:
- character_changes:
set_motivation: "{character} wants to tell {player} that their favorite animal is the {{p.favorite_animal}}."
set_core_description: "{character} loves {{p.favorite_animal}}s. They are quick to tell {player} fun facts about {{p.favorite_animal}}s. {character}'s favorite animal is the {{p.favorite_animal}}."
For example, if the cat is selected, the Motivation are set to: "{character} wants to to tell {player} that their favorite animal is the cat."
and the Core Description is set to: "{character} loves cats. They are quick to tell {player} fun facts about cats. {character}'s favorite animal is the cat."
For more information on utilizing Parameters see Customizable parameters changing action in runtime.
For more information on modifying character fields at runtime checkout Character Mutations.
Relationship and Emotion Mutation
The Relationship and Emotion Mutation showcase is an example of how Character Mutations can be used to dynamically update the Emotion and Relationship parameters of an Inworld character at runtime.
In this example, you can set the Trust Level of the Trust Innequin to compare their willingness to provide secret information to the player with differing relationship parameters and emotional state.
In the Unity Playground demo, the Trust Level can be set using the provided UI panel. There are three Trust levels to choose from, either Suspicious
, Uncertain
, or Trusting
.
When you select a Trust Level, a trigger is sent to the server to activate a goal corresponding with the level of trust. Note how the Relationship and Emotion parameters are modified depending on the Trust level in the Goals YAML below:
Suspicious
goals:
- name: trust_level1
repeatable: true
activation:
trigger: trust_level1
actions:
- character_changes:
set_relationship: ENEMY
set_relationship_primitives:
trust: -1000
respect: 0
familiar: 0
set_personality:
negative_positive: 4
cautious_open: 2
introvert_extravert: 2
set_mood:
disgust_trust: 2
set_emotion: ANGER
set_motivation: "{character} doesn't want to tell player any information at all."
Uncertain
goals:
- name: trust_level2
repeatable: true
activation:
trigger: trust_level2
actions:
- character_changes:
set_relationship: ACQUAINTANCE
set_relationship_primitives:
trust: 0
respect: 4
familiar: 4
set_personality:
negative_positive: 6
cautious_open: 5
introvert_extravert: 5
set_mood:
disgust_trust: 5
set_emotion: NEUTRAL
set_motivation: "{character} wants to find a way to trust {player} but isn't ready to share secrets just yet."
Trusting
goals:
- name: trust_level3
repeatable: true
activation:
trigger: trust_level3
actions:
- character_changes:
set_relationship: CLOSE_FRIEND
set_relationship_primitives:
trust: 1000
respect: 9
familiar: 9
set_personality:
negative_positive: 9
cautious_open: 9
introvert_extravert: 9
set_mood:
disgust_trust: 9
set_emotion: JOY
set_motivation: "{character} trusts {player} now, and wants to tell {player} all his knowledge."
When Suspicious is selected, Trust Innequin will not want to share anything with the player when prompted.
However, when Trusting is selected, Trust Innequin will share with the player that they know of a secret hidden sword that can only be seen at night.
For more general information on using Character Mutations with Inworld see here.