- Home /
Question by
unity_VQ79J25WmrMJqQ · Jul 29, 2020 at 01:58 PM ·
physicsraycastdots
[ECS] Move a collider to another collider
Hi,
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?
Thanks
Comment
Answer by andrew-lukasik · Aug 02, 2020 at 08:41 AM
float3 dirToTarget = math.normalize( targetPos - myPos );
float3 destination = targetPos - dirToTarget*( targetRadius + myRadius );
Your answer
![](https://koobas.hobune.stream/wayback/20220613004340im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Physics.Raycasy not really using Layermask? 1 Answer
How do you detect collisions in DOTS Physics? 0 Answers
SphereCast Arguments 1 Answer
My raycast wont function properly 0 Answers