How do I get a variable from a character blueprint in to my level blueprint?

Hi there,

I have a blueprint which checks if a character is in my pre-formed array of characters, and if it is it will cast to the character and affect the movement of it.

My question is, how do I get the ‘Health’ variable from one of these character blueprints, and alter it from within my level blueprint?

I ask because I’m using overlaps, which are in the level blueprint, but would like to change the health value of any player within the radius each second until they leave. I can’t seem to figure out how to pull my ‘Health’ variable from one blueprint into another.

Thanks in advance!

on actor overlap get the overlapping actor and you might have to cast to that character to get the variable you need.

I’m not sure I follow. Here is what I have: https://i.imgur.com/hASXc3u.png

After the Cast_To_Character node I’d like to affect the variables of the Character BP- is there a simple way to do that? Apologies if I’ve just misunderstood your answer. :slight_smile:

Something like this

I looked at your picture i don’t get what it is your trying to do … why are you trying to call the class vs the character directly ?

Wait are you trying to effect the pawns ?

From the image i see that your casting to a character … not sure if its in general or are you trying to target a specific character in my image I am targeting specifically the third person character that interacted with the box. (I actually used it as a check but still) you should be able to get bp variables from the as character node without a problem.

There are several different character blueprints all within my array, so I’m just checking that whatever has overlapped my TriggerBox is one of those before continuing.

I think I’m perhaps just a bit too tired to be trying to comprehend this or perhaps to get my idea across properly.

I have an array Character Pawns which contains Character blueprints. Each of these blueprints has a variable inside of them titled ‘Health’ which I want to be able to change from within this overlap sequence.

Unless I’m mistaken, by the time my script here reaches its end it knows that what it is dealing with is a character blueprint, which is why it can alter the Character Movement. What it doesn’t know is which blueprint it is dealing with, so I cannot access blueprint-specific variables.

My question is, how do I do this?

Thanks for taking the time to answer this!

oh.

got ya .

the overlap return should tell you witch one but i know there are occasions where it does not tell you which one.

I solved this for someone with a simple is valid check using castto that ran down the list of characters and would return which number the character was …

basically the person named his characters
character 1
character 2
etc … anyway

Ill include the blueprint paste bin of that function in this post.

but you can use is Valid or cast to as a way to find out which one and cast to it.

in my case i couldn’t use a for each loop but in your case you might be able too.