# increase a certain value ratio

hello guys

on my game i have a player input from 0 to 1 based on mouse y axis.

to score i have to get 2 point, so it should go from 0 to 1 and go back, for the next score the variable in this case i’ll call

float _score;

i have to increase it by a constant of 1.2f, so it will be 2.4 (2 * 1.2)
then with mathf.floor i get an int of 2, so i want to create an algorithm that take the floor throwed 0.4f then add it to the constant of 1.2, so i’ll get an constant of 1.6 on the next time that player scored, so it’s are going to be harder

i can’t figure out how to do it (mathematically)

Hi,
Your question is very hard to visualise. Would you mind posting at-least some code ? It would hopefully make your question a bit clearer.

(Be sure to read this before using code in your post: Using code tags properly )

ok, i’ll do my best, i don’t have code with me but is something like this.
i know that i will get some problem with it but is just an example.

``````    private float _constant = 1.2f;
private float _numOfcurrentcut;
private float _necessaryCut = 2;
private float _ratio;

// Use this for initialization
void Start ()
{

}

// Update is called once per frame
void Update ()
{

}

private void Movement()
{
_ratio = Mathf.Clamp01(1.0f - (Input.mousePosition.y / (float)Screen.height));
if(_ratio > 1)
{
_numOfcurrentcut += 1;
}
float targetZ = Mathf.Lerp(2.0f, -3.7f, _ratio);
Vector3 currentPosition = transform.position;
currentPosition.z = Mathf.MoveTowards(currentPosition.z, targetZ, 2.0f * Time.deltaTime);
transform.position = currentPosition;
}

private void UpdateNumberOfNecessaryCut()
{
if(_numOfcurrentcut >= _necessaryCut)
{
_necessaryCut = Mathf.Floor(_necessaryCut * _constant);
// the object that i should cut is going to be bigger
// so i want to increase the number of cut with a constant of 1.2
// now i will get 2.4 rounded to 2 with math floor, what i want is add
// the throwed 0.4 to _constant so on the next step it will be multiplied by
// 2.6 and so on.
}
}
``````

You mean something like this ? :

``````private void UpdateNumberOfNecessaryCut()
{
if(_numOfcurrentcut >= _necessaryCut)
{
float original = _necessaryCut * _constant;
_necessaryCut = Mathf.Floor(original);
_constant += original - _necessaryCut; // Add to the constant
}
}
``````

That should do everything you asked for.

Also, this in your `Movement()` function does not do anything:

``````if(_ratio > 1)
{
_numOfcurrentcut += 1;
}
``````

Because you clamped _ratio with `Mathf.Clamp01` so it will never be greater than 1.