I wanna setting my c++ variable in Blueprint


I temporarily set the character’s altitude.

Then I took my variables from the blueprint.


In the game, if I overlap my character with a coin made from a blueprint, I want to raise the maximum altitude, but it doesn’t work.

How do you declare “altitude” variable?

on your second screenshot it seems like your actor won’t be able to execute anything after the destruction, because it is destroying itself.

altitude is an arbitrary variable I declared

Are you saying that changing the order will work?

Actually, I did this first and it didn’t work.

at least now the blueprint can executed that bit of code :wink:

if you can’t set your altitude float in any way, I’d have guessed (like ) that it has something to do how you setup the variable. Another reason could be that some function is always overwriting the value.

In you blueprint I don’t understand why you are setting the value of your altitude with it’s own value and then adding the altitude score, that you set to a fixed value of 2000 right before that. The first two set functions seem kind of unnecessary, but I don’t know your whole code.

Yea, that is odd…but maybe the altitude variables are just poorly named. One needs to be pulled from the ABCharacter reference, the other seems to exist in the current BP making me think they are 2 different “altitude” variables. Mixing the C++ into this, one is clearly defined in C++ and one or more could simply be blueprint variables of the same name. Either way, this is a very, very odd setup.


I had to solve it this way.
I had no knowledge of blueprint and I studied.
Thank you