How do I set up proper Blueprint communicatoin?

Hi there, I am fairly new to Unreal Engine and one of my biggest problems is understanding proper blueprint communication. For example, let’s say I create a new player character (that the player doesn’t control), and in its BP I set up an “OnClicked” Event for the capsule component that simply print’s “Hello”. How would I create that same functionality (so when I click the capsule component of this new character the string is printed), but inside of the BP of the player character that the player controls? I feel like every way I know of doing this, is a lot more complicated than it should be. So what is the easiest, most straightforward way of doing this? Any tips would be greatly appreciated!

So the player can click the NPC, and it says ‘hello’, but the code is in the player? :thinking:

Hi, thank you for your reply. Yes I know it sounds counterintuitive, but the “Print string” is only as an example. What I really want is to set a variable when clicking on the NPC, and use that variable in the player BP. This is a lot easier to do if the whole thing would be in the player BP (it’s hard to explain why^^). I have also had a lot of other situations where I needed similiar functionality, so this is just an example really.

That’s a bit messy.

Two ways ( among many ) you can do it

  1. Have your usual on clicked event in the NPC. In that event, send a message to the player character with the info you need

  1. When you click the mouse, use a line trace to talk to the NPC, and get the variable that way.
1 Like

Thanks mate!

2 Likes