Download

Bp vs ai

Hello everyone,

I’m preetty new with learning AI system in UE4, and I was wondering what is the exact difference between BP & AI in order to make NPC.

1 - I mean, is AI a much powerfull tool, that can make things not possible to do with BP ?
2 - Is it also (or only) easier ?
3 - And/or better optimisation ?
4 - Is AI system still up to date as BP are, or are this feature not so updated nowadays ?

Thanks for your help !

Hi Krystoh,

When you say AI, I’m assuming you are talking about behavior trees and AI perception (not pawn sensing), so here’s what I’ll say:

  1. AI (as in behavior trees) and the way logic is setup is more flexible. Writing everything in a BP means it’s contained to that BP. Both systems use BP in some way, so I’d say both are capable of achieving the same behavior, but may differ on the performance side of things

  2. BT and AI perception show up in the new debug mode (press ’ and then numpad 1,2,3,4 to toggle modes) which makes troubleshooting easier than debug strings in BP (though it’s sort of a preference). However, if you have never done AI before, learning BT can be a challenge since it is a new way of thinking. You end up with a lot of individual assets (BT Tasks and whatnot) where as blueprints are self contained for the most part (if that’s comfortable already). So it may it easier for some people, and really is better suited towards AI that is involved. A simple “follow the player” AI would be fine in BP for example.

  3. BT is claimed to be optimal because it is a dedicated state machine rather than the general functionality of BP (although there is the option to nativize blueprints AND it depends on how complex the AI behaves overall). The assets made to support BT’s (Tasks, Decorators, etc.) are meant to be designed generically so that they can be reused in different BTs.

  4. The AI system, assuming you mean AI Perception, is still in development from what I gathered. So it is not “done” or optimal for that matter, but AI Perception is not necessarily part of BTs. It is used in conjunction, usually to set boolean flags in the BT for when the pawn detects the player. Pawn Sensing is still around and works just the same because they aren’t tied to BTs.

You may want to look into the Action RPG project by Epic. The AI (including player) use BTs. This might give you an idea of what’s accomplishable.

On a **personal **note, I don’t enjoy working with BTs from scratch. Blueprints are easier to prototype with, but harder to debug by comparison. I will get my AI working in BP and if I need to optimize their behaviors then BT becomes an option. In regards to AI Perception vs. Pawn Sensing, I would say AI Perception is better because it detects when a target is seen and unseen. Pawn Sensing works on a regular interval (default 0.5) and does not notify if the target is unseen (you have to check for this yourself). There are other differences, but this tends to be a big one for me since it’s about knowing when the target is in sight or not.

Thank you @ConradG for your **time **& your **help **and for your detailed response !

I better understand now differences & also get your interesting point of view. :slight_smile:

Glad I could help. Keep looking into the systems to decide what’s best for your needs. I’ve used both and over the years developed a preference.

Hi @Krystoh

The difference is:

  • AI is the name of the subsystem and method that controls the Agent/Bot.
  • Blueprints is the scripting language you script the AI Subsystem with.
  • If you don’t favor Blueprints, you can implement AI in UEC++.

There are several methodologies to approach AI: Rules-Based, Finite State Machine, Behavior Trees, and several others.

  • UE4 has a Behavior Tree (BT) Editor. It uses Blueprints for scripting the logic for tasks and services in the BT.
  • UE4 also has State Machine Editor in the AnimBP that could be dual purposed for AI. It too uses Blueprints to script logic.
  • You can also script AI with BPs WITHOUT using the BT or State machine Editor. I’ve created some decent AI using just a Switch Node and *Name *Datatype Variable for States.

Optimization is dependent on how you implement your logic in Blueprints.

All are updated when UE4 are updated.

Thanks @ConradG, yes I’m learning and I’ll decided after depending on what I need like you say. :slight_smile:

@TechLord Thank you a lot for your detailed response. :slight_smile:
I understand now the different approach ! I’ve already used state machine fiew time, but now I’m learning BT and I like the way it work.

Sorry guys for my late response, however I didn’t received any notification !

You’re very welcome. I would also encourage learning the basic concepts of BTs outside of the UE4 implementation. Most of the UE4 BT tutorials I’ve reviewed use States, but, the key difference between Behavior Tree and State Machine is that the primary building block of a behavior is a task rather than a state.

Good Luck to you on your Game Dev Journey.

Thank you @TechLord for your help & advice, and sorry for my late response (didn’t see it before !) :slight_smile: