this question is engine agnostic, I will use the term "object" to refer to entities in my scene.
The scenario is the following:
- I have 2 entities
- Entity O is a capsule
- Entity C is a point
I want to move B toward A's center but stop on A's surface in the less computationally expansive way I can think about.
I figured I'd work out the distance between the center of the capsule and the point on the surface where I should stop and use it as an offset to my destination point (destinationPoint -= direction * computedDistance), but I don't know how to find that distance.
My question is: can you come up with a better way to achieve my goal and if not can you solve the problem I've stumbled upon in my solution?
This is a representation of the secondary problem. In the figure I know the coordinates of C, O, A, B, and I want to know the length of PO or the coordinates of P.