Ecosystem ai demo

About the project

This was a little class project where I was tasked with making a simple behavior system for various types of animals. The animals in the scene are represented by colored shapes and interact with each other and the player. The terrain you see is just a 100X100 randomly generated floor based on oscillations.

territorial

Territorial is an animal behavior where the Object sits still and when a certain type of Object enters its “Zone” it will chase them off. The way this is written in code is that the Host Object has a collision sphere around the Host at a certain range and when a Intruder enters that range the Host will lunge towards the Intruder and then stop moving. If the Intruder is still within that range after the Host has lunged it will do so again until the Intruder is out of range.

skittish

The second behavior is one where the Object will wander around the space in random directions pausing occasionally then wandering off again in another direction. If at any time the Skittish Object gets too close to a player or to a Territorial Object the Skittish behavior will run away in the opposite direction of the player or territory. The fleeing effect is triggered by a foreign object entering a collider and detecting an Object relative to the location of the Skittish entity. The Object then moves at an increased speed in the opposite X,Y direction of the offending Object. After a short time the Wandering behavior resets and the Skittish Object resumes walking around.

hive particles

This behavior is non-reactive and can also be applied to particles to create a kind of “Stink cloud“ or “This character is seeing stars“ effect. It consists of a Hub (or Hive) and attached objects that float around it. The random movement over multiple axis is done with random seeded velocity and amplitude oscillation effects.These random values though are reined in by a maximum distance from the hub area, this keeps them localized to the Hive.