AI Steer Behavior: Obstacle Avoidance
- itzvnodm
- Sep 18, 2014
- 1 min read
Used Sphere VS OBB detection to detect collision.
//If collided resolve the collision by applying lateral force
Vector3 Direction = mSphere.c - transform.position;
//Calculate the lateral steering force
Steering = (rigidbody.velocity - Direction).normalized;
rigidbody.AddForce(Steering * MaxForceFactor);
The code also handles multiple collision by finding the nearest collidable sphere and resolving the collision with that sphere first.


![Flappy Bird clone ! [Using my own C++ Game Engine]](https://static.wixstatic.com/media/5ab37f_6f5eaa61ba744460bf8bbc86ef50cc47.png/v1/fill/w_306,h_250,fp_0.50_0.50,q_35,blur_30,enc_avif,quality_auto/5ab37f_6f5eaa61ba744460bf8bbc86ef50cc47.webp)
![Flappy Bird clone ! [Using my own C++ Game Engine]](https://static.wixstatic.com/media/5ab37f_6f5eaa61ba744460bf8bbc86ef50cc47.png/v1/fill/w_38,h_31,fp_0.50_0.50,q_95,enc_avif,quality_auto/5ab37f_6f5eaa61ba744460bf8bbc86ef50cc47.webp)
Comments