Skip to main content

Overview

There are three kinds of behaviors. Simple, Neighbor and Ray. The defaults library contains several implementations for each kind of behavior [1], [2], [3]. They can be added to a SteeringSystemAsset in the editor.

Implementing New Behaviors

The framework provides a simple way to create your own behaviors. There are generally three parts to implement.

Job

The behaviors are implemented as Jobs which loop through all entities in parallel and calculate one result per entity, normally of type VelocityResult. There is some logic which would be the same for all behaviors of a certain kind. For example, neighbor behaviors will for each entity want to loop through each of its neighbors. To simplify creating new behaviors, there are custom jobs for each kind of behavior. When creating for example a simple behavior, you can do so by creating a struct implementing the ISimpleBehaviorJob interface. The three interfaces for behavior jobs are:

note

Special thanks to Jackson Dunstan who wrote a blog post about creating custom job types.

Job Wrapper

A job wrapper is what is serialized into the SteeringSystemAsset when adding behaviors in the editor. Jobwrapper's main purpose is to schedule the job which has the actual logic of the behavior. However, it can also contain additional serializable properties for this behavior, which can be set in the editor. The Schedule method of a job wrapper can also contain some additional setup logic before the job is scheduled if necessary. There are three interfaces for job wrappers:

Component

Each kind of behavior requires that the entity has some component on itself which parametrizes the behavior per entity. There are three interfaces for components: