I have an AI the relies on Force to move, but I need it to flee from the player's position once it reaches a certain distance. Normally this wouldn't be a problem, but once they hit a wall, they get stuck and using OnCollisionEnter doesn't help since they will force themselves towards the wall until they get locked. The game runs in 2D with the Z-axis locked. I tried the bounce material with similar results and raycasting is out of the question.
Question: How do I get the AI to flee from the player, but go the opposite way once it hits the wall, without touching the player?
asked Mar 26, 2011 at 11:04 PM
Just one advise for checking the distance with the playes, take a look to colliders, specially to the OnTriger...() functions .
Then with the wall staff, I'm trying to figure out that what you want to get is just a constant minimum distance respect the player, so why not OnTriggerStay?
If you it is not exactly what you need, please give me more details.
answered Mar 26, 2011 at 11:51 PM