I am new to game programming I currently am using unity's 2D power to remake an 2D game for sake of practice. So I am just little confuse about one thing, so far every enemy in my game was dumb(they move on predefined paths) but this enemy, alien-copter, flies and follow the player wherever the player goes. My question is should I implement any pathfinding algorithm? I had studied A* but I trying to figure out if A* is gonna be helpful in my envoirnment because player will be moving and the enemy have to keep on looking for shortest path. I tried to write code for this AI my code was working perfect when there were no obstacles but my game has obstacles so I want something efficient so what do you people think should I implement A* or any other algorithm or not?
closed as primarily opinion-based by Seth Battin, congusbongus, Anko, MichaelHouse♦ Jun 9 '15 at 22:25
Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.
without any clues of what your game looks like, what platform it is aimed for and what are you willing to do I'm going to try to give some hints (since I myself have been in your place):
- Research games that look alike the one you're making;
- Contact the devs of such games, converse with they implementations and strategies;
- Do some reverse engineering.
- You asked: "my code was working perfect when there were no obstacles but my game has obstacles [...] should I implement A* or any other algorithm?" Yes, yes you should. That's just the next step to know if the algorithm will be suitable for your game;
- Experiment with navigational meshes, waypoints, different heuristics and note down the results to compare and evaluate;
- Also https://gamedev.stackexchange.com/a/73740/30632
And lastly, when I was first learning path-finding algorithms, I used to make tons of little test cases to see how would the agent behave in certain situations and how could I make it do better by tweaking the heuristics and etc.