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.
Comments