I've been following this tutorial: Understanding Steering Behaviors: Collision Avoidance
but I'm having trouble implementing one of the functions correctly in Unity, here's the code:
private function lineIntersectsSphere(ahd:Vector3, ahd2:Vector3, sphCol:SphereCollider) : boolean
{
return distance(sphCol.center, ahd) <= sphCol.radius || distance(sphCol.center, ahd2) <= sphCol.radius;
}
The SphereCollider
variable contains the Center
variable, however, it always returns a vector containing 0, 0, 0
values. I imagine it's the spheres local origin.. is there a way to get the center? Perhaps it could be through the transform.position that the sphere is attached to?