Subtracting float not working

Hi,

I have looked at other examples and this should be relatively simple and for the life of me I have no idea why this is not working.

Here is the part of the script not behaving itself.

using UnityEngine;
using System.Collections;

public class Money_keeper : MonoBehaviour 
{

	public float money_made;
	float money_in;
	public float powercost_total;

void Update () 
	{
	  // money_in and Powercost floats are numbers that add up over time. These figures work fine.  
          money_made = money_in - powercost_total;
        }

public void damage_cost(float ouch)
	{
		Debug.Log (ouch);
		money_made -= ouch;
	}
}

When I run the game and the script that runs the damage_cost executes I can see that the figure is carried over fine via the debug log.
What is not happening is the money_made float is not being subtracted by the float ouch.

That’s because you’re resetting the value of money_made to money_in - power cost_total on every frame.

Ok,

After taking a long coffee break and returning to my code I saw the obvious that smacked me like a semi truck.

Here is the code that works

 using UnityEngine;
 using System.Collections;
 
 public class Money_keeper : MonoBehaviour 
 {
 
     public float money_made;
     float money_in;
     public float powercost_total;
     public float damaged_mac;
 
 void Update () 
     {
       // money_in and Powercost floats are numbers that add up over time. These figures work fine.  
           money_made = money_in - powercost_total - damaged_mac;
         }
 
 public void damage_cost(float ouch)
     {
         Debug.Log (ouch);
         damaged_mac = ouch;
     }
 }

I was looking at my own script wrong. The money_made was not compounding each update (in fact if it was compounding then I would hit million negative credits in a few seconds, not what I want). The damaged_mac will grow each time it would be called and would subtract from the total money_made while the other money influence floats do their thing.