• Register
Post news RSS Basic AI System (Actual Gameplay Video)

A video showing off some pathfinding and basic AI for the Yakuza Gangsters in my prototype level.

Posted by on


I just had another one of those “I’m really doing it!” moments this week as I finally got some AI chasing and attacking logic implemented in the game. When I say AI I’m not talking about SkyNet this is really just a series of commands that tell my enemies in the game how to react to the player character. The current Yakuza hive brain can be broken down like this:

  • Patrol your designated area
  • If you see Neon follow him until you are within firing range
  • If you are in range fire your uzi
  • Reload and fire again until Neon is Dead

It seems pretty simple when broken down and realistically it is but this is just the first layer. As I add Stealth and Combat into the mix things will get a little more interesting.

Comments
evgenidb
evgenidb

How you do this part: "If you see Neon"?

Will the enemy see Neon if he hides behind something or you just check if the distance between them is less than a predefined value and nothing else matters?

Also, could you make Neon (and possibly other characters and objects) "fly" back when they get shot from the uzi? I think it's both more realistic and could be thought as a potential hazard, e.g. if Neon is near a building's edge and the gangster shoots him, Neon could fall from the building.

Currently (or at least in the video) he just lands in the same place after the "get shot" animation.

Reply Good karma Bad karma+3 votes
stuhp84 Author
stuhp84

Right now I'm in the beginning stage of AI and it's just checking the distance and range. The next step will be for the baddies to check if Neon is "stealthed" (which would be a check to see if he's interacting with an object tagged "stealth object") and if he is then it would stop attacking and just go back to patrol.

The knock-back thing is an awesome idea and something I'm going to look into as I add a more robust combat and collision system.

Really appreciate the thoughts evgenidb!

Reply Good karma+2 votes
stuhp84 Author
stuhp84

I misclicked and deleted your reply so I'm reposting it...

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

"I'm assuming you're writing the game in C#:

Won't it be easier to implement if you make just a new property for the class Neon (or however you have named it). It could even be a Boolean.

Example:
public bool isInStealthMode { get; private set; }

And you set it to true when Neon is in stealth mode (when he starts interacting with stealth object) and to false when he is not (when he stops interacting with such
object). And then the enemy/everyone-else should only check this property to know if Neon is visible or not.

You can even use it to have enemies that are stealthy too. Such as ninjas.

And if you want, you can go even further by making it into enumeration (enum) and have various states/modes: Normal, Stealth, LowProfile,... For instance, LowProfile could be for some enemies (assassins) that hide among civilians and are indistinguishable from them. You won't know they're the enemies until you get close to them and they take out their guns, and knives, and katanas..."

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Reply Good karma+2 votes
stuhp84 Author
stuhp84

I am writing the game in C# and that public bool idea is pretty much what I had in mind but you are doing a much better job putting into words.

The multiple stealth modes idea is good to think about since I am planning on having some enemy types that use more traditional stealth (blending into shadows) and I would like to have one of the harder levels be really dark so Neon looks more exposed giving the enemies "the advantage".

These states being coded instead of just being a visual thing could be the basis for some kind of "ninja sense" or "special item" that reveals enemies that are stealthed near the player. Lot of fun options to mull over.

Reply Good karma+2 votes
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.