Sending variable between character blueprints with interface function?

Hi,

I’m trying to send a variable from one character blueprint to another, doing it via a blueprint interface. The reason I am doing it via blueprint interface is the problem with “cast to [insert character blueprint name]” when I have several playable characters. It seems easier to me to simply call it in the relevant character blueprint of the active player instead.

Anyway, I know how to set the values in the blueprint interface function in the relevant character blueprint, I am able to send it to the target blueprint. But I am having problems actually using the value sent. In this case, it is experience points. Here is the setup in the enemy character blueprint:

Now, when I do a print string of this function in my playable character blueprint, I get the values as they should as I slay my enemies with gay abandon. At the moment of death the enemy sends the value just fine. Now the issue is using it… Not sure how. Tried setting a variable, it gets set and then stays there which means it keeps ticking up XP constantly. Not optimal. Weird thing is that when I do the print string in the function, it prints 0…0…0… then the experience value as the enemy dies. Then 0…0…0… But when I try to set a variable by it, the variable just stays at that value. I guess that’s because it doesn’t technically ever send 0, it just prints the 0. Anyway, looks like this:

Now it may well be that my entire setup is completely borked… Any ideas?

Should add I’ve managed to “trick it” into working, but problems occur when multiple enemies die at once. Using the variable setup from above I have the following:

267469-bpi-prob03.png

][1]

Now this certainly isn’t very elegant, and as I said it doens’t work.

If anyone has any other ideas how to send a variable from one character blueprint to another that would be most helpful. Without using cast to specific character blueprint.

Alright went over this and figured out what I did wrong. My interface function had both an input and an output - It doesn’t need that. Something got messed up when I initially made the function so I was unable to call the BPI event properly, therefore had to make the tacked on solution that I did.

Thought I’d show the correct way of doing this in case anyone was wondering. For clarification: This is a way to send a variable between two blueprints WITHOUT using “Cast to”, ie you can use this for any characters without any casting.

So, I setup my BPI function:

267532-bpi-prob01.png

I went to the blueprint (be it character or actor) that I wanted to send the value (in this case an enemy AI) and added a message to the BPI function:

267533-bpi-prob02.png

In this case “other actor” is the actor hit by a line trace (IE the enemy can see my character, then sets the character it sees as “other actor”).

I then went into my playable character blueprint and grabbed the amount of experience and used that as an input value for an experience gain function I am using:

267534-bpi-prob03.png

So there you have it, sending a value between blueprints without “cast to”. In this case, upon dying, the enemy AI sent my character its experience value which I can set individually for each AI character.

Nevermind… Guess I fixed it by doing this:

I am a bit worried that I am taxing the engine unecessarily though. A simpler way would be greatly appreciated. Plus it has a tiny bit of lag on it which is kinda annoying.

Slight update, the “other actor” variable is not needed. “Get Player Character” does the trick.