Don't Walk By - 5

Don't Walk By - 5

Feb 21, 2020. | By: Evan Diamond
1 min

The fifth CGD blog post about Don’t Walk By

Overview

For this week I started working on the AI script as both the density grid and touch manager systems are completed for now and are stable.

AI script

The ai script is a wrapper around the two components of the ai the A* pathfinding and the flocking. Each AI has a state which it can be in these states are:

  1. Stationary - The Ai is not moving
  2. Default - The ai is pathing to moving points of interest
  3. Path to Point - The Ai is moving towards a point
  4. Path in direction - The Ai is moving in a direction until it hits a wall
  5. Calculating route - The Ai’s pathing is done asynchronous meaning that there can be some delay before the find their route to path along.

Users of the ai can call set functions which will cause the ai to swap to one of these states and perform its respective behavior. I implemented the functionality of the stationary and default states.

Stationary

The stationary behavior is simple to implement as I just had to clear the list of points which the AI is uses to path.

Default Behavior

The default behavior entails the ai pathing to a point of interest (currently a random point) waiting there for a random time between two values before pathing to a new point. To implement this I created a default state sub state which can either be: getting a new path, pathing along a path or waiting at a point.

Default demo

State Info

I also added a struct to the ai class that hold information about the ai’s current state. This includes:

  1. Their previously mentioned ai state
  2. The direction the ai is moving in
  3. The list of points that make up the Ai’s current path

A user can call GetStateInfo() to retrieve the current StateInfo of the Ai.

About

Gamers developing new games.

Social Links

Our Bunker

University of the West of England,
Frenchay Campus, Bristol, BS16 1QY,
United Kingdom.