- Home /
Walk Aroud a Target Randomly
Hey,
What I currently have is that a AI can approach a given target (say a box), after it gets there I want it to randomly walk to one of its sides. What would be a good approach to implement this?
Answer by zakkar · Mar 02, 2012 at 12:21 AM
Make an array which contain different box, test if there is a collision with one box, if true then yield and choose a random element from (random array.length)
Answer by kevork · Mar 01, 2012 at 11:13 PM
Determine the N (assuming 3, the sides other than the side the AI is currently at) other positions you would like to move to. Check to see if those are valid positions to actually move to. Randomly choose one (if any) of the valid positions. Move to the randomly selected position. Upon arrival, repeat the process. You can cache some of the results per box.
$$anonymous$$y main problem is deter$$anonymous$$ing the positions around the box, as the boxes are not in static positions and can be placed.
Your answer
![](https://koobas.hobune.stream/wayback/20220613064645im_/https://answers.unity.com/themes/thub/images/avi.jpg)