Is +=, -=, *=, /= etc. possible in Blueprints?

How can I perform Compact Operations on Variables in Blueprint?

I want to alter my variables a few times before a single operation is performed, so how can I do compact statement in blueprint? Is it as simple as getting the Variable the setting it again?

No by default, you would need to code such nodes yourself in C++ (dont panic its quite easy, you just add something to funtion to convert it to blueprint node) but im not sure if blueprint system and UHT support primitive type varable pointers in order to set blueprint varable just by inputing it.

1 Like

Hmm seems you’re right, I can’t make multiple changes to a variable before something is done with it.

Kind of sucks really, I can’t get the current state of a variable and add to it. Does that mean I’m going to have to create multiple variables, which are all ‘older’ versions of one another, and do it that way?

Going to take forever :frowning:

Well look like theres blueprint solution, see below

1 Like

Interesting, but what did you search for to get that Set Int (By Ref) node, because I can’t find it.

1 Like

under each input there is a checkbox that lets you pass by reference. if you check that, the circle pins turn to diamond shapes and dragging off of one of those diamond pins will give you a context sensitive list of functions that you can perform on pass by reference variables.

1 Like

Ah I see, many thanks! I’ll see if this works.

I’m going to use this function multiple times in the same tick on a variable, but this pass by reference thing should be the solution you think?

Here is where I’m stuck now… notice the first ‘Set Alpha’ function. How would I go about using it here, or would I have to condense all of this into a special node like the above?

1 Like

im not really sure what you are trying to do, but doing something multiple times per tick sounds like the kind of thing you would want to do in C++ for efficiency.

right now, you are multiplying Alpha vectors X and Y by itself every tick, which will exponentially increase the values of Alpha very quickly. unless some other code limits or resets Alpha, this seems like a problem. are you trying to add a velocity to alpha?

1 Like

what is the functionality you are trying to achieve?

1 Like

Here’s the thread, which I’ve linked to the code. You can see that it makes multiple changes to a variable as it’s passed through the code, in a specified sequence, before outputting that value to either Angular or Linear velocity. (Alpha is Angular, Accel is Velocity). Both values are acceleration for the ‘Omega’ or ‘Veloc’ Vectors which are the actual Angular/Linear velocities respectively.

I’ve been trying to program it as a movement component for some time now, but having bugger-all luck.

I should add that the C++ there IS wrong of course, I still have limited knowledge and have a lot to learn about Unreal’s Movement Comps. They’re… complex.

The Psuedo-Code I have however is taken from a working game (by a proper programmer)

Seeing that your formula correct using the “math expression node” to type custom math code will make it easyer.

Since I catch myself using such operations a lot and hating the time wasted everytime I have to use the “Branch” node, I’ve recreated these operators (and some more) in the form of a Plugin which you can find here:

https://github.com/BrUnOXaVIeRLeiTE/UE4BPExtensions

The nodes I’ve added have branching built-in when needed and removes the necessity to output a boolean value to link to a Branch node all the time when simply checking something, pretty much like the “IsValid?” node.
Just copy the “BxBLExtensions” folder into the Plugins folder of your project, restart the editor and nodes will be there.

■■■■… nice one Bruno! Bit of a necro :stuck_out_tongue:

Con++;
Screenshot_5

Con+=0.001;
Screenshot_4