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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.