hi! I want to add some air density. I know, there is a function, where i can set the min and max. and a value. based on that it should give me a number between 0 and 1 basen on the altitude value

its something like that:

```
float min = 0f;
float max = 200000f;
float value = 50000f;
float airdensity = maths.something(min, max, value);
//airdensity = 0.75f??
```

XxJonas_YTxX:

hi! I want to add some air density. I know, there is a function, where i can set the min and max. and a value. based on that it should give me a number between 0 and 1 basen on the altitude value

its something like that:

```
float min = 0f;
float max = 200000f;
float value = 50000f;
float airdensity = maths.something(min, max, value);
//airdensity = 0.75f??
```

Should be simple.

Lets just make our own formula for it.

Let value = 50 and max = 100

```
50% of 100 = 50
50% = 0.5
0.5 * 100 = 50
rearrange
0.5 = 50/100 (value/max)
```

So, we have 50, (â€śvalueâ€ť in your case) and we have 100 (â€śmaxâ€ť)
When we divide them we get a proportionality.

But given that your air density is 0.75 with those numbers, I assume you want inverse, so just 1 - calculated value.

Itâ€™s different if your min isnâ€™t 0 though. Use max - min for max in this case.

Yoreki
September 16, 2022, 6:21pm
3
Should be (Val - Min) / (Max - Min)

1 Like

mgear
September 16, 2022, 6:43pm
4
this thread has some options too, for remapping ranges:

The straightforward answer is Mathf.InverseLerp:

This is a special case of the remapping functions discussed in the above-linked thread.

thanks! thats exactly what I need! I just multiplyed the wing lift factor with that value. that simulates a kina realistic space.