@kennyist Use Mathf.InverseLerp(a,b,value) method. gives you the result from 0.0 to 1.0f.
for example mathf.inverslerp(50,100,yourfloat=50) = > result will be 0.0 and your speed will be 0
and Mathf.inverselerp(50,100,yourfloat = 100) => result will be 1.0. and your speed will be 4
and Mathf.inverselerp(50, 0 ,yourfloat = 0) => result will be 1.0. and your speed will be 4
Mathf.inverselerp(50, 0 ,yourfloat = 50) => result will be 0.0. and your speed will be 0
So we can proceed with following checks
if(float >=50)
{
speed = mathf.inverseLerp(50,100) * 4f;
}
else if( float <=50)
{
speed = mathf.inverselerp(50 ,0 ( zero only not hundred) ) * 4f;
}
,Use Mathf.InverseLerp(a,b,value) method. gives you the result from 0.0 to 1.0f.
for example mathf.inverslerp(50,100,yourfloat=50) = > result will be 0.0 and your speed will be 0
and Mathf.inverselerp(50,100,yourfloat = 100) => result will be 1.0. and your speed will be 4
and Mathf.inverselerp(50, 0 ,yourfloat = 0) => result will be 1.0. and your speed will be 4
Mathf.inverselerp(50, 0 ,yourfloat = 50) => result will be 0.0. and your speed will be 0
So we can proceed with following checks
if(float >=50)
{
speed = mathf.inverseLerp(50,100) * 4f;
}
else if( float <=50)
{
speed = mathf.inverselerp(50 ,0 ( zero only not hundred) ) * 4f;
}