- Home /
How to prevent objects from interpenetrating eachother ?
So i have a bunch of objects which get some random position and i want to prevent these objects from interpenetrating eachother. The player move around these object and when he is close it's repositioning randomly the object. So it is possible to precalculate a position where we are sure there is a space large enough to contain the object, depending on its scale, rotation, animation or whatever else for preventing interpenetration ? Is there an effective and efficient way to achieve that ?
Answer by Piflik · Dec 29, 2012 at 12:27 PM
You can use a recursive function that calls itself again if the position is invalid and returns the valid position once it is found. But you will also have to limit the recursion depth, or you will get a stack overflow (function calls itself infinitely), if there is no valid position.
Your answer
![](https://koobas.hobune.stream/wayback/20220613090059im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Stop platforms spawning inside player 1 Answer
Increase Drag Distance?? 0 Answers
Raycast doesn't register Rigidbody 1 Answer