# How to perform a substraction inside a float function that is being called in update dynamically (Only Once)?

Hello I wanted to ask how can I perform a substraction of 5 variables that are constantly being changed from a float function. Here is some code so you can understand what I mean:

``````float x = 1;
float y = 1;
float z = 1;
float g = 1;
float i = 1;

float Total

void Update()
{
Total = SubstractVariables(Total);
g++;
}

public float SubstractVariables(float SubstractionResult)
{
SubstractionResult = SubstractionResult - x - y - z - g - i;

return SubstractionResult
}
``````

This currently substracts every frame those 5 variables, so they decrease every frame. What i want to achieve is make this substract dynamically. Any help is kindly appreciated!

I hope I understood what you want to achieve.
So this should work out

``````    float x = 1;
float y = 1;
float z = 1;
float g = 1;
float i = 1;

float total;

void Update()
{
total = SubstractVariables(total);
g++;
}

public float SubstractVariables(float _total)
{
_total -= (x + y + z + g + i);

return _total;
}
``````

Greetings,
Max