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