I’m trying to do some simple integer manipulation in Blueprints, but for some reason, when adding 0 to an integer, it’s instead subtracting 1…
No, you are subtracting 1 and then adding 0. The net gain is then -1.
What are you even trying to do with this?
Size X at the start is 1, so I subtract 1 making 0. I then add that 0 to X. X is originally 4, but for some reason 4 + 0 = 3.
Watches in blueprints are far from helpful, but the first one is the result after the subtraction, top one is the original X value, bottom right one is result of addition.
Basically with the inventory segment, Grid X,Y is it’s location on a 0 based grid. Wheras Size is 1 based. So i’m using this to make a Box2D out of Grid and Size values. To do this I need to convert SizeX,Y to be 0 based
( GridX,Y + ( SizeX,Y - 1 ) ) = Box2d Max
Have you checked that it is set up properly? IF you did not it will return a size of zero. Print the value you get from size and print x and then see what you get.
Does the same issue happen with the other side with Y?
Only other possibilities that I can see are:
- SizeX is a value other than 1, like 2
- X is not defaulted to 4, but 3
What I like to do in these situations are to print the values for each step of the way so I can see exactly where the mess up is happening. Using the exec node above, try adding print nodes with the values at each step of the process, so at the initial value of SizeX, the value after subtracting 1, the value after adding X to SizeX - 1, so forth.
I’ve double checked all my input and it’s definitely coming out as “1 + 0 = 0”. To get on with it I just made a branch ( if x - 1 == 0 then don’t do the addition ). I feel dirty but at least it works.
Thank you to everyone who helped out.