Take nearest point of target object instead of center

Hello,

when I am setting my seekers target to a big gameobject, targets center point is taken but in most cases it is not what is desired. I want my seeker to go to the neerest point to the target object. Is it possible?

1 Like

I solved the problem with modifying AIPath.cs script. For the ones who is interested here is what i did:

I added the public bool “GetTargetsClosestPointToCollider2D” and update the part of “SeachPath” function to set thetarget.position to closest point of the target transforms collider2D

public virtual void SearchPath () {
		if (target == null) throw new System.InvalidOperationException("Target is null");

	lastRepath = Time.time;
// This is where we should search to
Vector3 targetPosition;
if (GetTargetsClosestPointToCollider2D) //LEVENT
{
    targetPosition = target.GetComponent<Collider2D>().bounds.ClosestPoint(GetFeetPosition());
}else
{
    targetPosition = target.position;
}
1 Like