Hi there! I was just wondering, what (in your opinion) is the best way to approach putting NPC AI into a UE4 C++ project? I have not built any AI in UE4 before. Thanks for your help!
The Shooter game example and Tom Looman’s Survival game are nice and provide a good start. Check their source.
First – what type of game? A turn-based strategy will be different from a tower defense game, which will also be different from a first-person shooter.
That said, the C++ API documentation for AAIController is here: AAIController | Unreal Engine Documentation
This lists a lot of the methods that UE4’s default AI controller can do for you.
Thanks!
A third person simulator with AI that simply are designed to walk around as NPCs to make the world feel a bit more inhabited than just solely the player.
Then you can simplify the Shooter bot AI :
- if the NPC does not have a target location, you need to get a random point on the navmesh, and set it as target location (can be a Service in the Behavior Tree)
- if target location is set, start AIMoveTo to this target location
- reset target location on arrival, to repeat the process automatically
I have implemented that to some extent. I have also made it so that actors are spawned periodically from the AI. I have the objects successfully being spawned (I can interact with their OnOverlap) but for some reason they lack a mesh.