Collision avoidance

Predicting collisions is a very useful thing to have been implemented into our AI characters and can be used on crowd systems too in order to make the crowd move more organically when one character is walking on the direction as another character as we saw in the previous chapter. Now, let's take a look at a simple way to implement this feature:

To predict a collision, we need at least two objects or characters. In the preceding image, we have two spheres representing two characters and the dashed lines represent their movement. If the blue sphere moves toward the red sphere, at a certain point, they will collide with each ...

Get Practical Game AI Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.