7. Calculate operations and purchase costs
Build this example in your Unreal project and compare the result at each step.
On this page
In this exercise, you will check individual calculations and a purchase with increasing prices. Use the BP_MiNumero you created earlier; you do not need additional assets or sample files.
- Open its EventGraph and keep the flow calculate → Is Success → Branch → show value or error.
- Search for an operation from the table in the graph menu. Create its inputs with Make Scientific Number; leave Exponent at 0 for these values.
- Connect the result to the checking flow. Compile, press Play, and compare with the table. Stop Play before changing the operation.
- If the node returns a bool and Out Error, check the bool with Branch and use Out Error on the failure branch. Connect white pins when the node has execution pins.
| Operation | Inputs | Expected standalone result |
|---|---|---|
| Subtract | 3000, 2000 | 1000 |
| Multiply | 2000, 3000 | 6000000 |
| Divide | 3000, 3 | 1000 |
| Power | Base 2, Exponent 10 | 1024 |
| Square Root | 144 | 12 |
| Apply Production | Current Value 1000, Production Per Second 25, Delta Seconds 4 | 1100 |
| Arithmetic Purchase Cost | Num Items 3, Price Start 100, Price Add 50, Current Owned 0 | 450 |
| Max Affordable Arithmetic | Resources Available 1000, Price Start 100, Price Add 50, Current Owned 0 | 5 |
The cost of three units is 100 + 150 + 200 = 450. With 1000, you can buy 5: they cost 1000 total; six would cost 1350.
When finished: you should be able to change an input, repeat the calculation, and explain its result before applying a format.