- Home /
Float, make percentage
Hello, how to make 80% from float 25 ?
public float number;
void Start () {
number = 25f;
}
void Update () {
If (Input.GetKeyDown(KeyCode.A)
{
number = number / 100 * 80;
Debug.Log(number);
}
}
}
But this don't work, thanks for help .
Comment
Best Answer
Answer by StaNov · Sep 17, 2015 at 11:11 AM
Try to multiply the number by 0.8 instead of dividing and multiplying again:
number *= 0.8;
Beware, the number gets lowered every time the A-button is pressed.