Is there an event system that tells me when a value is exceeded or deceeded?

I need a system that notifies a function with float and a bool paramater when a certain value went through or below a ten multipler(like 10, 20, 30 etc).
I’m thingking of a definition like this:

void TenProcessor(float threshold, bool positive){
// Where threshold is the ten multiplier that got passed(10, 20, 30, 40, 50 etc)
// and positive indicates whether is the value went above the threshold (positive: like from 19 to 21)
// or below the threshold (negative: like from 21 to 19)
}

Now I need a way to monitor the value and to set the preferred thresholds(tens) and a mechanism to determine if it was exceeded or deceeded? Is there such an event system?

Had you tried C# events or Publisher/Subscriber pattern?

It seems to me like a set{} property would be enough to do what you need.

Sorry, but I’m not asking about the delegate implemetation or the set accessor, I can look up MSDN for a memory refresh on those things.
I just need to know how to actually check for milestones, do I use a conditional statement with a temp variable that stores last values and check EVERY possible number against the old value which seems an overkill, or is there a simpler and cleaner solution for tracking value dynamics which I believe should have posted in the Unity Wiki for all to use. I think someone already has it because I think it’s almost imperative for state check on alot of different gendres of games.

??

I don’t get your question. The usual way is conditional statements checked when you need to test them. “If (variable > xxx)” and “Switch state{ Case STATE_STOPPED:}” etc. In the case of your example, you’d need a temp var to record previous value after update to test against. If it’s a particular type of value you want to track, you could roll it into a class and define a ‘ChangedBorder’ method, returning True/False or threshold value passed.

I was thinking something like that :

float myValue;

float MyValue
{
	set
	{
		if(myValue > value)
		{	
			if (Mathf.Ceil(myValue/10) > Mathf.Ceil(value/10));
			{
				TenProcessor(Mathf.Ceil(myValue/10), true);
			}
		}
		else if (myValue < value)
		{
			if (Mathf.Floor(myValue/10) < Mathf.Floor(value/10));
			{
				TenProcessor(Mathf.Floor(myValue/10), false);
			}
		}
			
		myValue = value;	
	}
	get
	{
		return myValue;
	}
}

Wow, Zuru I really appreciate you writing 30 lines of code to help out, I made some ad hoc changes, here it is:

	private float percentage = 0.0f;//......//
	public float Percentage
	{
	    set{
	        if(percentage > value)//Falling below a 10X mark 
	        {   
	            if (Mathf.Ceil(percentage/10) > Mathf.Ceil(value/10))
	            {
	                TenProcessor((Mathf.Ceil(percentage/10)*10)-10, false);
	            }
	        }
	        else if (percentage < value)//Exceeding a 10X mark
	        {
	            if (Mathf.Floor(percentage/10) < Mathf.Floor(value/10))
	            {
	                TenProcessor((Mathf.Floor(percentage/10)*10)+10, true);
	            }
	        }
	        percentage = value;    
	    }
	    get{
	        return percentage;
	    }
	}

It works like a charm for a percentage value, the only drawback is that when the value changes dramatically quickly some steps may get missed, but otherwise for a reasonable speed of change the property works fine, Thank you very much.

when the change is quite big, you can do Mathf.Ceil(percentage/10) - Mathf.Ceil(value/10) to know how many steps have been skipped.