Re: Logically coding logical AI's that do logical things?

These are great questions and @magurp244 has covered most of what I was going to write on this subject. With respect to AStar, I've found it to be the most useful and actually employ it in TDV quite successfully.

Since we're talking about instant turns here, you can definitely use a aim-and-shoot situation for your NPCs. The trick here is you don't want your NPC to turn too quickly, so you need to set a delay or have them turn faster or slower at random. The alternative is to have them turn instantly, and since we're not using graphics here we don't need to simulate anything turning. So all you need to do is get the angle between the NPC and the player and shoot in that direction. This is simple enough to do:

            float X = 0f;
            float Y = 0f;
            X = X1 - X2;
            Y = Y2 - Y1;
            TheTa = Math.Atan2(-X, Y);
            if (TheTa < 0)
            {
                TheTa = TheTa + 2f * PI;
            }
            return (int)((float)TheTa * 180f / PI);

Now the object at x1 y1 will need to face those degrees to form a straight line to x2 y2



-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : nolan via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Munawar via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : dardar via Audiogames-reflector

Reply via email to