Kinematic Steering
During the summer break I wanted to keep my programming knowledge fresh.
I found a few videos about Steering Behaviors that led me into doing Flocking Boids. Ultimately this became a Movement Controller that I used in our Game Projects.
Flocking Boids
- TGE (school's engine)
With 3 simple Steering Behaviors the goal was to create a simulation of flocking boids.
-
Cohesion: Tries to steer towards the average position of other units within a defined vision, handing out linear force.
-
Separation: Tries to steer away from nearby units by handing out linear force.
-
Align: Tries to match the direction of facing with other units within a defined vision cone, handing out rotation force.
The core concept of the Steering Behaviors is that each behavior gives out a steering in some direction of some magnitude. Either rotation(angular) steering or linear (velocity) steering.
Keeping each behavior quite simple gives us the ability to combine multiple rather small building blocks that together form a fluid and smooth movement.
The Kinematic class then takes in the combined steering output from the behaviors and applies it on the transform. Updating the position, orientation and adjusts velocity, rotation forces based on the angular and linear force.
Steering Controller
- Kitty Engine (own)
In order to simplify movement for the users, the controller takes care of all the overhead stuff.
The controller owns the steering behaviors and the Kinematic class to keep the rotation and position up to date.
We can simply assign a target to the controller which utilizes the pathfinder for navigation and assigns targets to each steering behavior based on our next waypoint in our path. As we progress along the path, the controller assigns new targets to each steering behavior to get movement and rotation in desired direction.
Each frame the controller hands the combined steering to the kinematic update which solves the rotation and position of the game object. And if we were to use 2D Pathfinding, it can adjust the height of the gameobject to handle slopes as well.