Attempt at implementing obstacle avoidance using raycasting in a 3 steps process;
- Bezier algorithm guided curve movement using pure timer along pre-calculated path, regardless of obstacles.
- Every so often, raycasts are used to determine actual terrain obstacle in front of the unit. If an obstacle is detected, a preferred path is calculated regardless of the Bezier curve result.
- Using both algorithms, the unit will attempt to move along Bezier curve position, while raycasting algorithm will try force it back to a straight-line movement. With a careful alternating between both, an actual movement path is formed.
Obviously…the algorithm work fine only when there is no influent from other units in the same area. Perhaps flocking algorithm could help in that regards.