My predator object in my game scene exhibits random movement. It will rotate on the spot by a random amount and then move forward a random amount. I’m using a raycast to determine whether it should be allowed to move or not (whether there is an obstacle in it’s path). I have mountains surrounding the area with mesh colliders attached. They are all tagged as ‘obstacle’ and I need the most efficient way (there are about 20 of them) to check if the predator would collide with them. I have a Vector3 called targetLine that stores the difference between it’s current position and it’s target position.
what you can do, is you can use a Vector3.Distance () in the update function,
Get all your objects, loop through them, measure the distance of each 1 to the predator, if you are too close to one of the objects, change the predator movement to a tangent/other direction, make him rotate around the object if you want with rotate around function.