How to extract the highest value?

Hi commUnity.

I have got a value that is coming out of a motion controller (Razer Hydra) and I need to extract the highest value of it (over time). Like if the value rises and than begins to fall more the about 10 units take the latest value and store it in a variable. So I think I have to measure the growth of it and if the growth is than like -10 store the latest value.

Do someone has an idea how to say this in script(C-sharp)?

Hopefully you understand what I try to ask.

Thanks!

1 Answer

1

I’m hoping I understand you correctly

(javascript and untested, sorry)

//curNum is your input variable
private var maxNum : float;
private var checkDecline : boolean;
   
function Update () {
    
if(checkDecline)
{
	if(curNum < maxNum)
	{
		//it started going down
		//do stuff

		//reset maxNum
		maxNum = 0;
	}
}

//reset decline check
checkDecline = false;


if(curNum > maxNum)
{
	maxNum = curNum;
	checkDecline = true;
}
    	
}

curNum would be your number youre getting from input

and then you could probably make a tolerance variable to add to the if statements

also there’s probably a more elegant solution with something here but I am too dumb

Hey Tim, thanks for your answer, but I guess this is not what I meant. I need to find the moment (the frame) where the curve of the value changes from going up to going down. I guess it's called the tipping point. And I also need a tolerance so that minimal -+changes wont influance the final result.

sorry i thought you wanted something else, i edited my answer to the only way i can think of at the moment you should probably edit your question title to have "tipping point" in the name and wait for a better answer