- Home /
Strange AI
Hi all, I'm using a waypoint system for my racing AI, and am using triggers to determine if the racer has reahed a waypoint. The AI takes the position of the targeted waypoint and localizes the position. If the position of x is less than 0, it turns left; if it is more than 0, it turns right. However, sometimes the AI turns away from the waypoint without being hit or affected and crashes into the wall, and just stays there, and keeps going forward, even though the wall and it has zero friction (can turn along the wall) and the waypoint is just a few meters left from it. Sometimes, it turns but goes back the wrong way of the track. What can be done to solve this?
Many thanks!
Answer by roamcel · Feb 05, 2012 at 07:57 AM
You are facing one of those problems that can be solved with infinite solutions ranging from one-line-simple to impossibly-complicated, so it can be difficult to pinpoint a cause for the issue.
Anyways, my guess is that the 'direction algorithm' you're using is only called upon the waypoint trigger, right? Whilst you should instead call it repeatedly over time to be sure that no external event misleads the ai and sends it forever into the wrong direction.
For that you could use the 'InvokeRepeating' function.
Thanks. It solved one of my problems but many of them are because of one careless mistake of leaving a gap, so some cars miss the trigger and thus go back, explaining the problem.
Thanks though. $$anonymous$$ay it come in handy in the future. ;) lol
Answer by Kryptos · Feb 05, 2012 at 08:28 PM
Have you considered using UnitySteer (a porting of OpenSteer)? It has a Vector3PathWay defining a set of waypoints and a SteerForPath behaviour that can control your AI.
Your answer
Follow this Question
Related Questions
How To Add AI To Car/Racer? 4 Answers
Race Interfaces 0 Answers
"AI"/Behaviour for a Waypoint system 1 Answer
Ai turning problem on Android - Question solved 0 Answers
Waypoint System help 1 Answer