I am currently creating an environment to train aim-bot AI's for my game. It is a 2d world made of complex polygons, and the goal is to have the AI's shoot ricocheting bullets. Using a ray-casting algorithm, I can tell whether the bullets are inside or outside the shape, but I do not know how to calculate the nearest edge of the polygon (so I can send the edge to a reflection function to reflect the vector of the bullet). Is this process even the best way of doing things:
- if the bullet will end up inside of the polygon in the next move
- reflect the bullet's vector based on the slope of the nearest edge