Hello,
I am a relatively new programmer building a spaceship game and I'm at the point where I would like to add in some (basic) interesting A.I.
Right now there are two AI 'options'. One of them is just moving directly towards the player. The other is shooting at the player. I want to make the movement more interesting (right now it is just in a straight line towards the player.)
I would also like to take this opportunity to learn pathfinding. My idea is to 'draw' some invisible barriers that the enemy ships cannot pass (walls if this would be a ground based game). The enemies would have to strafe around these barriers to get a clear 'shot' on the player. Of course the barriers are not actually visible in the game world, so I think it would make for a cool effect. Attached is an illustration of the idea.
[attachment=28323:pic1.png]
[attachment=28324:pic2.png]
In pic 2, the red barrier (could be another map layer that is 'collidable') blocks the line of sight from the ship, so it has to scoot around the side to get a clear shot.
My questions:
1. What terms should I be looking up / reading that are relevant to this cause? I have read about A star pathfinding… is that applicable in this situation? Remember I don’t want the ship to literally hug the wall, but a ‘smooth’ strafe around the side of it. (Starcraft 2 style… I wish)
2. How does pathfinding and AI interact? Who is the ‘boss’ so to speak. Is it pathfinding that tells AI “go here now, go here now” or is it AI that asks pathfinding “Where do I go, is this clear, can I shoot now?” What is the order in the update loop?
3. Is this kind of situation a constant (per update loop) “polling” type situation (like controller input), or an event type situation (like perhaps two objects colliding), or a combination of both.
4. I have read that things in game programming should be decoupled as much as possible, is that also relevant in this case?
Thanks for all and any assistance.