Currently working with Lucy on AI. Setting up a dynamic waypoint system to simulate what we'll likely have in the engine.

UPDATE FROM LUCY - No longer working on AI.

Kudzai's Grid Waypoint System

Hey Neil, since you the one working on AI, along with Lucy, this is mainly for you guys to consider if you'd like to implement or not or you may choose to develop it or not or try it out if you like but I was sitting on my behind the last hour and this came to mind…

  • it will work on for bot navigation in straight lines
  • the waypoints can be any distance apart
  • it is mandatory to have waypoints at corners and junctions so as not to have bots walking through walls
  • collision detection of bots and rooms may be ignored as waypoints guide the bots
  • it may be made to apply to a certain type of character or all characters
  • for characters that walk on walls or upside down on roof tops it will be most effective with changing a few variables
  • it is also mainly hard-coded but may be made alterable for application when creating a more generic waypoint system
x1 x2 x3 x4
z1 _ _ _ _
z2 _ _
z3 _ _
z4 _ _ _ _


Using the grid above, there may be a corridor marked with the bounds where wall1, wall2, wall3, wall4, wall5, wall6, wall7 and wall8 shown below:

  • wall1 = (x = x1 && z < z4 && z > z1)
  • wall2 = (x = x4 && z < z4 && z > z1)
  • wall3 = (z = z1 && x < x4 && x > x1)
  • wall4 = (z = z4 && x < x4 && x > x1)
  • wall5 = (x = x2 && z < z3 && z > z2)
  • wall6 = (x = x3 && z < z3 && z > z2)
  • wall7 = (z = z2 && x < x3 && x > x2)
  • wall8 = (z = z3 && x < x3 && x > x2)

Now we can set up a hypothetical waypoint system for a patrol bot which moves in this square corridor… The waypoints will take three variables:

  1. a name… duh!!
  2. an id number
  3. a location/position reference

Now the name is used for the creation of the waypoint, while the id number is that of an ascending value starting from 0. Each room which can have bots will have waypoints that start from 0 and this will be mandatory. Waypoints will also have to be made in an order which can be followed by the ascending/descending protocol thus, for example, a bot can decide to move from = 86 (Waypoint086) to either = 85 or = 87 (Waypoint085 and Waypoint087 respectively). The bot cannot decide to go to Waypoint083 or Waypoint000 all of a sudden.

Now for the waypoint system to be created, the use of structs may be employed to hold these three variables. The name is a string variable, id an integer and the position reference is a vector3 variable which may be used to move objects when applying changes to their matrix coordinates in the world.

Id numbers would have to be assigned manually and the position and name hard-coded (but it will be easy to use Waypoint000, Waypoint001 and so on). The bots movement is thus assigned to a the Matrix.CreateTranslation() function in the update method whereby a random number generator may help the bot to decide the direction to take e.g.

int num = random.Next(2); // generates a number less than 2 i.e either 0 or 1

when getting to Waypoint000, the number may be generated and if it is equal to 1, the bot may advance to the next Waypoint… the waypoint with id equal to + 1. On a higher waypoint, if the number generated is 0, the bot will thus go back to the previous waypoint i.e - 1.

When the waypoint matching the id is found, then the bot's location will thus be… Matrix.CreateTranslation(waypoint.position) whereby waypoint.positon is a Vector3 variable.

Well enjoy putting this to code and I will help if you need any help getting around this or implementing this… your success is mine…

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License