C++ attributes vs. BP attributes

I followed an online course to help me with the basics of c++ with UE4 (I have 0 previous experience with c++). In doing this I did learn some neat stuff, however I’ve now come across an issue. In the c++ we set values for things like health, mana and stamina. my issue now though, is I’m trying to implement my talent system (in BP) and had to create variables for those stats in order to increase them with talents. Im noticing that they are increasing when i select my talents but they seem to be reverting right back to my default values setup in my c++. How can i get around this or stop this from overwriting itself?

You have screen shots of the C++ code and of the blueprint implementation? Kind of hard to help without seeing what is going on.

you set c++ defaults in constructor?

The thing is, my blueprints are just calling variables that i created as “current health” and “max health” etc. but those variables are fighting with the c++ “health” and “Max health” counter parts. at this point I’d honestly just delete the c++ code for those if i wasn’t worried about them messing something else up and just use my BP variables instead. But the c++ ones are there for my ability system.

271379-screenshot-3.png

basically all i need is a way to call/modify the “Health” and “Max Health” that I created in c++ in BP format. is that possible?

Yes, where are you “health and max health” C++ variables declared? Are they "blueprintreadwrite? What do you mean “they are increasing when I select my talents but then revert to C++ defaults”?? What you have shown isn’t really helping much, I don’t even see your variables, just some functions relating to them. Are you trying to call C++ functions from blueprints to change a C++ variable or are you trying to change a C++ variable within blueprints?

Also I noticed in your functions do not take any reference variables, so basically they are making copies and not changing the actual C++ variable.

is this it? I’m sorry im completely useless with c++ but this appears to be it to me.

Just add preffix to the arguments, like CurrentHealth or CurrentMaxHealth. Also in C++ support variable shadowing, so in case of you having 2 variables declared in diffrent scopes with same name, one declered on higher scope will be used. So function arguments have higher priority over class varables as they higher in the scope. But you can always reference to class varbales with “this” pointer

But back to topic, explain your case more. Show us example of case in detail how you trying to set variable.

Well you asked for screen shot of “blueprint implementation”, so he give it to you ;p

So it turn out I have to write a function in c++ to be able to set/ get these values properly. And since i don’t have even close to the knowledge to do this, I think I have to scrap my game and the hundreds of hours I’ve wasted on it so far… :*(
thanks for the help guys

Looks like you’ve written plenty in C++ already, creating a function to set/get your variables shouldn’t be hard. Also I’m 100% certain you don’t need to do that in C++ if you declare your variables properly using “Edit Anywhere, BlueprintReadWrite” or some other specifiers for your particular situation. Pretty sure something is off in the blueprint code that you have yet to show us that is causing your issues. So you can show us the blueprint stuff and the issue or you can start over I suppose, up to you.