Love/Hate Faction system

Announcements, support questions, and discussion for Love/Hate.
Post Reply
KeithBrown
Posts: 1
Joined: Mon Aug 05, 2019 4:08 pm

Love/Hate Faction system

Post by KeithBrown »

Hi, I am working on implementing some AI for animals and was wondering if I could use Love/Hate for interaction between the different types of prey and predators. What I mean is can I setup different factions for say a deer and a wolf, and if the deer detects the wolf it will know to flee and likewise the wolf will know to attack? But if the deer comes across a rabbit then it will just ignore it?
User avatar
Tony Li
Posts: 22093
Joined: Thu Jul 18, 2013 1:27 pm

Re: Love/Hate Faction system

Post by Tony Li »

Hi,

Sure! In fact, Love/Hate includes a Farmer Example scene. From its readme:
In this non-interactive scene, rabbits wander the field. Wolves eat rabbits.

Rabbits will learn to avoid wolves. The farmer will learn to dislike wolves for eating his rabbits. The wolves will learn to avoid the farmer.

This is driven by affinities. As wolves eat rabbits, other rabbits will lower their affinity to wolves. When affinity is low enough, they'll flee wolves. As the farmer sees wolves eat rabbits, he'll lower his affinity to wolves. When affinity is low enough, he'll chase wolves.
You can always set the affinities from the start, so that rabbits always know to flee wolves. But the example above goes a step further and shows how rabbits can learn to flee wolves after seeing fellow rabbits get eaten by them. It does all this with a minimum of overhead and no post-initialization memory allocation (i.e., no garbage that needs to be collected).

You're welcome to try the evaluation version. It's built for Unity 5.6 - Unity 2019.1. The next update's evaluation version will work with Unity 2019.2. The Asset Store version works with all Unity versions up through the latest 2019.3 alpha (i.e., all available Unity versions).
Post Reply