Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm not sure if there's a better way to ask that, but I have a hovercraft which hovers by imparting force at each of four corners. I'd like to clamp the maximum variance between the thrusters so if one corner hovers over something higher altitude, the effect is less dramatic.

For example, if I had 4-6-8-10, I might want it to compress to 4-5-6-7.

share|improve this question

2 Answers 2

I would actually recommend normalizing towards the mean (average) rather than the lowest value.

base_values = {4, 6, 8, 10};

double ave = average(base_values); // ave is equal to 7

for(int i = 0; i < base_values.len; i++)
{
    base_values[i] = base_values[i] - (abs(ave - base_values[i]) / 2);
}

abs(...) is the absolute value function.

That will make going down jagged terrain look good, as well as going up.

share|improve this answer

From what you posted I see a pattern you could use. Here is some psudocode

values = {4,6,8,10}

lowest = 100 //or some other imposible high number
for each int in values {
 if int < lowest then lowest = int
}

for each int in values {
 value = value -((lowest-value)/2)
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.