B plus c up to 100 then set c to remainder of c after 100 or 0 if under 100. How do I write this equation in ue4 blueprints to automate returned value
Hey leaf042! Welcome to the forums!
Would you possibly be able to write this out in mathematical notation?
I’m a bit confused by the wording.
Can you say what this is for and what the values of B and C would be in your game?
I have a regenerating integer that I’m using to fill up a flashlight battery along with other things but only when selected and I can’t figure out how to only remove what it added to the other integer. For example if my battery is at 75 and it adds the 25 to make it a hundred but it had 50 it should still have 25 but I don’t know how to write that equation into the UE system to calculate that.
Also how do I keep it from saying that was the solution here because that was the question I’m asking with more detail but from what I’m seeing it said that was the solution even though it has not been resolved
Try using a clamp node!
Set your max to whatever your Battery Max Capacity is, and the Min to 0, then the return value would be your flashlight battery value. So if the input value is over 100, but the battery max is 100, it’ll round down to 100. Same if you went below minimum, it’ll round up to minimum (0 in this case)
Also I removed the solution tag for you no worries!
So are you wanting the battery to function like a power bank?
- Flashlight battery at 90, power bank at 50.
- Use power bank.
- Flashlight battery now at 100, power bank at 40?
I am using a clamp so possibly my mistake is earlier because I’m using battery Plus charger to set the battery through a clamp but then my question becomes how do I remove from the charger what was added to the battery because that’s where the math is going haywire and I feel that I’m over complicating it
When you add to the Flashlight from the battery,
- Get current flashlight charge
- subtract current flashlight charge from 100 to get the difference, we’ll call it Charge Amount+
- Add Charge Amount+ to flashlight
- subtract Charge Amount+ from Charger
Maybe this could work for you?
Hooray you’re right to create a new variable and use the negative space of 100 - battery to get it and I was having some complications but the solution I missed it first was to set it earlier then the battery in the script line.
°set battery +
Use that order and get (battery+) from 100 - battery
Then use battery + charger to set battery and charger minus (battery+) to set charger.
Thank you very much and I did a quick rundown of how the fix worked as a thank you plus possible assistance to anyone who runs into the same problem in the future.