AI defending a certain area

How can I make ai defend a building? Can I use navmeshes to do this?

Hi, again ^^ what kind of defend you want, like patrol around building check for enemy near or just inside shooting out.

This is like a lucky day or something, anyways the patrol around building one

thanks man! Really appreciate it!

got it (realllllly appreciate it

I’m between tasks so have some time go around ^^ for patrol i think you can have 2 thing, one it task following path, and 1 it service which it search for enemy in certain range. First one, you can make a list of point, then just do MoveTo, when it reach target just set next target point. You can use this.

12295-movetopoint.png

For search for enemy, make 1 service blueprint you can run through list of you Character then check distance from AI to them.

Get the ones in range then check for line of sight, then if have enemy you can set value and tell AI to shoot him.

For line of sight check and sight range like 60 degree in front.
The way of line of sight it if it hit nothing between 2 character, player will in sight, you may include more point like from player eye location to enemy eye location, you can run this after find enemy in distance.

12299-line+of+sight.png

This to check he in front of you with some angle, not behind. And run this before check line of sight, my post not in order so rearrange yourself.

12300-sight+angle.png

One more thing you should run this per second of half, coz it will be expensive if you have a lot of player.

haha, last one need to get back to work, good luck with this ^^