Overview
Feelings is a system that allows you to give personality to your game characters, by balancing various feelings they might have towards the player (or other characters).
By maintaining a graph of relations between various feelings, the character evolves as the player interacts with him.
For example, in an RPG game, the system can give merchant a unique personality, such as an honest versus dishonest merchant, and have them adjust to the player behavior whenever he acts, such as buying something, threatening them, or trying to bribe them.
Feeling provides a simple FeelingsMap class, which you inherit from, and define the list of feelings and their relationships. The package includes 3 predefined implementations:
- Simple Love/Hate map
- Basic 6 feelings map: Sad, Mad, Scared, Joyful, Powerful, Peaceful
- Complex 42 feelings map: Similar to the basic 6 feelings, but with “sub-feelings”
Screenshots
Documentation
Creating a new feelings map
Start by inheriting from the FeelingsMap class:
public class SampleFeelingMap : FeelingsMap
{
}
Define the list of feelings as consts – this is not required, but makes things much easier to work with:
public const string Happy = "Happy";
public const string Sad = "Sad";
The define the relations between those feelings in the constructor:
public SampleFeelingMap()
{
SetEffect(Happy, Sad, -1); // When I'm happy, I'm not Sad
SetEffect(Sad, Happy, -1); // When I'm sad, I'm not happy
}
Here’s the full sample:
public class SampleFeelingMap : FeelingsMap
{
public const string Happy = "Happy";
public const string Sad = "Sad";
public SampleFeelingMap()
{
SetEffect(Happy, Sad, -1); // When I'm happy, I'm not Sad
SetEffect(Sad, Happy, -1); // When I'm sad, I'm not happy
}
}
Using a feelings map
Once you’ve created your feelings map, using it is quite simple. You can create an instance of the feelings map as a field:
private SampleFeelingMap feelingMap = new SampleFeelingMap();
Whenever something happens to your character, you apply feelings to it. For example, say the player gave a gift to the character – the character is now happier, so we’ll call the ApplyFeeling method:
feelingMap.ApplyFeeling(Happy, 2);
Now, whenever the character needs to make a decision, we can take its feelings into consideration. For example, will the character join the player on a quest?
var characterHappiness = feelingMap.GetFeeling(Happy) / 100.0f;
var joinQuest = Random.value < characterHappinest;
The happier the character is, the more likely he’ll join the quest.
Samples Scenes
The package comes with 2 sample scenes:
- Simple: this scene shows using a simple UI the impact of each feeling, in a basic 6 feelings map, on the other feelings. It uses the predefined 6 feelings map.
- Merchants: this scene shows how actions taken by the player can affect the prices requested by 2 merchants – one honest, the other dishonest.