UE5.5: Character Class BP with Player Interaction?

Hi again :slight_smile:

I have already searched the web but couldn’t find much of help with the following I am struggling with:

  • I have a BP of class character so that it can move around on a navmesh with AI_MoveTo, let’s call it “AI_Char”
  • My (first person) player char, “FPC, needs to interact with it, eg catching that AI_Char

I do know how to get that to work with actor class BPs but my enable input for interaction node isn’t working the same way on the character class AI_Char BP, in fact it does nothing.

Putting a print string behind the “Started” (EIS) exec pin of the IA_Interact node simply does not output anything.

I appreciate if someone could lend a hand and explain to me how to get FPC interactions working on character class BP.

Thank you!

Hi, you almost there.

In your AI begin play, give input to PlayerController

So when player makes an input action its received by the AI.

This gives me this in output log

LogPawn: Error: EnableInput can only be specified on a Pawn for its Controller

Oh got it, It is not actor but actually another pawn sorry for that.

So enable input won’t work cause pawns only receive input from its controller which is AI controller.

We can posses AI but it’s not what we want I assume since AI is doing movements etc, you are just trying to do an interaction with it on TargetAI Side. Correct me if I am getting this wrong.

So to put you to the right direction , you can do this 2 ways.

1: You tell target AI that IsInteracted
2: AI Listens player for interaction calls.

I will suggest you to go with 2. Why ? It’s more elegant and that approach can be extended more nicely.

1- Create an event on your player.

You can create an event by + icon in bp in the events section
image

I named it as TryInteract and dragged event on my graph then call it on IA_Interact.

An event can be listened by many things.

2- On my AI on begin play, get player pawn and cast it to its class (mine is BP_ThirdpersonCharacter)

This simply enables us to know the class of player. Since I have this I can do a lot of things with it.
Like I can bind onto the Player’s TryInteract() event and listen that on AI side.

If you want to extend this we can do an interface that you can implement to any AI or Actor. Also you can find pure BP but somewhat robust interaction design over here. : How do I add the "E" prompt to a movable object after I aim my crosshair in it? - #10 by RedGrimnir

Let us know further questions around it if any.

1 Like

Yes, that’s probably the best approach and had a feeling when fore-thinking that probably BPIs or EventDispatchers or even referrencing an actor BP would be needed.

I like that approach of yours and confirm it worked out succesfully , Thank you :slight_smile:

1 Like

My pleasure,

I suggest making it with an interface since you don’t have to cast. If you will push this further use interfaces with passing some arguments like
EventInstigatorActor
EventTargetActor

So actors can filter and check if the Interaction Event meant for them etc.

Also AI class won’t be referenced to Player which we desire to have, it bubles memory and additional cost, can cause significant performance drops in future.

Yes, absolutely true to consider BPIs as well. For now I’m good with what it is and see how many of those AI actors I’ll actually need and scale my way from there.