I’ve been rolling my own AI for my games, and Rob is accurate in that it is so specific to individual apps, that no one solution would be best. As SegaBoy references, AI theory can apply across platforms; you’ll be hard pressed to find a Lua-specific solution.
I’ve been doing a lot of work with Runtime loops and velocity checks to let my enemy objects know when a player is close, or if they have interacted with an obstacle. AI is notorious for breaking and/or not being mature enough for many games, and as a brief Google search will tell you, it has yet to be perfected.
Here’s a short snippet of one piece of code for one enemy in my game:
if GameSettings.enem1IsWalking == 1 and GameSettingsEnemies.enem1HitPoints > 0 then
if (lox > 90 or lox < -90) then
obj:setSequence(“running”)
obj:play()
ffQ = obj.Speed2
elseif (lox < 90 or lox > -90) then
obj:setSequence(“walking”)
obj:play()
ffQ = obj.Speed1
end
end
if loy <= 3 and loy >= -3 then
obj:setLinearVelocity(testx1, 0)
end
if lox <= 3 and lox >= -3 then
obj:setLinearVelocity(0, testy1)
end
This piece is demonstrating how one would set the sprite sequence depending on the distance of the enemy from the player. I’m sure you could adapt it to have it return your enemy to a specific location. Hope that helps!