How to make AI and Human character share the same parent BP?

For obvious reasons I’d like my AI characters have the exact same array of features that the human character benefits from. This asks for a common BP parent, which isn’t a big deal…

…however, how do I make AI controller use for example the weapon pickup feature that is normally bound to a keypress of the human player ? ( I’d isolate the functionality into a function but how to call that function at an appropriate moment from within AI controller ? )

Generally, how does one transfer the responsibilities of the human player onto AI controller ? I’m only just beginning to delve into AI, sorry if this sounds stupid easy.

Dare I bump ?

Your question is a bit vague, it’s not clear what problem, if any, you are trying to solve.

Basically, as you say it is feasible for the most part to use the same ACharacter-derived class for PCs and NPCs. Your character will have a set of actions/functions which it is able to perform, regardless of whether a human player initiates them (input handled through the APlayerController) or an AI does so.

My general approach is this:

  • Have functionality related to what a character can do in the ACharacter class.
  • Have any complex logic for how an AI-controlled character should go about doing these actions reside in methods of the AAIController class.
  • Put the higher level logic of choosing which behavior to do and when in the behavior tree.

Taking the weapon pickup example.
Your character class may have a PickupWeapon function, which requires the character to be next to and facing a weapon, and then adds it to the character’s inventory.
Your AI controller class has the built-in MoveTo functionality, but may add a function to smoothly rotate the player to face the weapon.
Your behavior tree is responsible for deciding at any given time, should the character go and pick up a weapon (if so, request a MoveTo followed by a RotateToFace from the controller), or should it do some other behavior.

Hope that helps.

What he may be asking is how to give the ai an inventory to be able to pick up items. This is the same issue I am having. I am trying to provide an ai with an inventory system that is accessible by the player, but I am having lots of problems.