Making AI that acutally behaves like a human

Ive been working on this A.I that behaves like a human and is hyperintellegent.

When spotting an enemy it calls its squad and gets the THREE closest ally’s to come over to it and help take the enemy down.

It will strafe and move around when fighting the enemy and will when handling melee weapons keep a distance.

Once it reaches its position it goes to patrol.

It has a a huge brick in the center of it that’s invisible that when touched causes it to go into attack mode and attack the person that hit it, it also does raycasting to check if they see the enemy.

It also plays voicelines.

At the end of every firefight the ai system gets

The person who got the most health taken away during battle
The guy who did the last shot to finish him off
The guy who contibuted the least

and assign a voiceline based on a huge table of lines

It also plays lines for spotting enemys as well and also general lines and comedic ones.

Does anyone have any suggestions on how I can make my A.I more realistic and behave like a human.

The best part is that this is all done by ONE SCRIPT. These ai do not follow a straight pattern where every one of them goes to one position and just camps. they split up, they fight seperatly and they play voice lines based on their separate situations

14 Likes

This system is really impressive, honestly! I can’t wait to see what you’ll create with it in the long run!

Maybe try to get them to move a bit more directly instead of doing the Gangnam Style dance! :rofl:

It’s pretty cool that you’ve managed to do all this with just one script, without any modules or anything!

That’s so neat! Do you think you might consider adding gender-tailored voice lines in the future?

1 Like

definitely when I need a use for gender tailored voice lines(When I get a female voice actor). The reason they dance like that when they reach their objective is because I just made them strafe around once they reached their goal, it was a placeholder system.

1 Like

why are you making so many pathfinding paths bro??

also i lowkey don’t understand how it behaves like a human???

2 Likes

Updated it to behave more humanily and work more independandtly while still moving in groups like actual soldiers

3 Likes

Oh my god the engine used to make kids games looks like… … a kids game. this is crazy

Thank you for this insightful observation you truly are the Socrates of modern times

2 Likes

Screenshot_20250519-125531.Chrome

Jokes aside, this is very impressive! The errors are a little bit scary, but it seems the AI bounces back! Keep up the good work!

Edit: I didn’t mean to reply to this person lol

6 Likes

Make character movement and orientation behave independently. Should greatly improve things.

1 Like

Its a reference to red vs blue season 2 where the sarge guy yells it before getting run over.

but the errors come from the test NPCS i placed to test the thing out Not the AI

New updated AI test (Better strafing and flanking. They acutally say alot more voice lines but I messed up the audio distance and set it to low)

1 Like

They can also fight each other

2 Likes

Nice, for future videos, can you give the soldiers bullet effects so we can better understand what is happening?

For more suggestions:

  • Make the soldiers slow down when taking aim.
  • More sideways straffing, make them look at the target and get the RightVector for the movement direction
  • The NPC’s distance management still feels a bit unrealistic; they should keep further distance from their target.
1 Like

Yeah I need to make a muzzle flash I orginally just made the soldiers weapons as aftertoughts as I was mainly focusued on the AI. They are shooting,

The problem with having the AI face you is that rotating the HumanoidRootPart causes the Moveto and pathfinding to stop and they just stand still. So I use a bodygyro which has a afterproblem of them not exactly facing YOU exactly. But they are still semi facing you

1 Like

For the orientation problem, disable AutoRotate, that’s the reason your characters aren’t properly facing the correct direction you want using BodyGyro.

By the way, I’m giving you feedback based on the NPC system we have in our game.

1 Like

awesome will do that king. Seems like a simple fix I missed.

1 Like

Ill be honest I have extremely high standards that push me to impossible goals sometimes. I think I will consider the AI acceptable when I add more behaviors to make it behave like a human.

  • Ill add a invisiable part to the charcter facing backwards from him thats attached to his HumanoidRootPart. When this part gets touched and the player is not crouching or uses his weapons that make a sound(Will rewrite the sound functions of every weapon) he will make a animation were he snaps back and turns around, plays a little spotted animation where he will point which will be less than a second and go to attacking the player alerting his squadmates

  • When the game reaches a MAX ai limit that I will determine through testing it will switch the ai from raycasting which is extremely expensive to a les expensive but less accurate system. Itll place a part in the HumanoidRootPart of every AI that will be extremely long and be facing forwards. The AI will then detect and scan for touches, and on a touch it will get the position of the object and if its a humanoid do a SINGLE raycast to see if it can see it can spot them from where they are looking to prevent the ai discovering the player if there behind cover and then alert its squadmates and fire. acutally I might just use that in general.

  • Add what im calling behavior emotions(name pending). Basically these are events or animations that happen based on events. For example if a Soldier kills a enemy and no other enemy is around it might go up and shoot its dead body a few times and say a voice line to make them more human. When low on health they might bring there arms up in a animation saying “ILL TAKE YOU ALL ON”(Of course ill have more than 1 line that could play because im a perfectionist at the expense of my own self sanity) and bezerk the player. Or if there is only one left they might flee in terror. Or if your staring at them for to long and are on there team they might say something funny “I know im good looking but we got a battle to win” or get angry at you.

Ive updated the AI model to

When shot at figure out who made the shot call 3 of its closest allys and strafe around and kill them
When moving in LARGE groups and there is a ALOT of ais don’t move independandtly move as a group for performance reasons. this does not apply in combat however
Detect teamnames for allys and the ability for ai to be on teams via the attribute TEAM

just for giggles I went and added a bunch of ai of them and put them on different teams to see JUST how many AI it would take for it to start lagging(I even removed the cleanup function so on death the ai would not be removed just to see if I could lag it and it stood its ground.) there were 23 ai although to be honest I think it could handle A LOT MORE ai than that before starting to lag(I also REALLY need to add new voicelines)

Its funny because when you get rid of the cleanup function they still talk despite being dead. it was funny at first but now its starting to become annoying those voicelines.

(Yes. one of them is saying “Mommy Mommy I have a tummy ache” and “Im wounded I need a lego star wars bandaid from target RIGHT NOW”)



I was shocked just HOW MANY ai I could fit.

101 ai at 136 smooth fps no drops or issues.


going to make a updated ai one with

Reaction based animations. when spotting a enemy they may play a point animation or a bruce lee like “Come over here” move. When damaged they might do a roll to evade and turn around
Handling of melee and ranged weapons
Updating the damage updating system and how they work as a group
Enemy taunting on death.

already have the basic models for the different enemy types.