[ECS] Move a collider to another collider


I want my character (basic capsule mesh with collider) to walk towards and then stop at a target (let’s say a box mesh with a collider). I can achieve this by calculating the distance between the translations, but that makes the character walking into the center of the target.

I wish to calculate the point in front of the box that my character should stop at in order to be close but not inside the box. What would be the best approach to this?


float3 dirToTarget = math.normalize( targetPos - myPos );
float3 destination = targetPos - dirToTarget*( targetRadius + myRadius );