Hello everyone. I started using Unreal Engine some days ago and it’s been great so far. I really love the Blueprint system and i enjoy it a lot. I was wondering how can i make a += -= /= *= operators using Macros? I am not really comfortable using C++ so i don’t know if its possible to make it without it. I haven’t really worked with macros but i think this is the way to make it. Thanks in advice!
Hi golfso, is there any specific reasons you would need macros? These functions are already built into the blueprint editor, just search for “math” and you will find all operations for different types of variables.
Hello, yeah i just need to do something like for example a Health Pickup. If the player have 53 health he would be able to pick a first aid kit and his health would go to 91 for example. And also i can’t find += in the math section. What i am trying to do is basiclly:
if(HealPickUp == isPicked) {
health += 25;
}
In Blueprint you would just explicitly Set Health = Get Health + 25. You don’t need += or similar macros.
There is a specific block for +=. look for ++. and you dont need to set the value afterwards either as you pass your variable by reference.
You could also write your own so that it passes the variable by reference to your function and the variable outside the function will be altered with the new values set inside the function.
read this up for bass-by-reference
Do not make macros for this, make functions, then turn them into pure functions (there is checkbox in function details panel).
And put those functions in function library. Be bit careful with function libraries to not make dependencies (ie. general purpose library should not reference anything from outside of it).