i’m writing a script for character that will be able to avoid obstacles.
the target is set on mouse click and in Update it is moving to the target.
i have a trigger sphere on it. and obstacles have colliders on them.
so on TriggerStay i’ve managed to understand how to get nearest point of collision (other.ClosestPointOnBounds(transform.position)) and direction vector by substracting char position from contact point. but i can’t understand how to correct character position, so it is somewhat deflected from wall smoothly while continue to move to target.
the best what i came to is calculating normal with Cross between forward vector and direction of contact and then calculating Dot product between forward direction and this normal vector. this gives a value with sign, but i can’t understand how to use it. may be it is totaly wrong approach?