Sending variable between character blueprints with interface function?
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?
asked Feb 04 '19 at 01:40 PM in Using UE4
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:
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:
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:
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.
answered Feb 04 '19 at 07:36 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here