Okay,
I have a variable called EnemyRemaining, which equals 30 to begin with, but an enemy is destroyed every 5 seconds (this bit isn't relevant)
So, my variable is decreasing from 30, to 29, to 28 ....
But I would like to display this as an overall percentage. When I have 30 Enemies Remaining - the overall percentage is 0% complete, then when all the enemies die off to 0 Enemies Remaining, the overall percentage is 100% complete (15 enemies = 50% ...)
Could someone help me with the equation and script.
Thanks
Solved it my self:
static var EnemyRemaining : float = 30; // Decreased every time enemy is killed
static var EnemyMax : float = 30; // Total amount of enemy to begin with
static var EnemyAdding : float = 0; //IMPORTANT BIT - Increases every time enemy is killed - from 0 to 30 -- this allows my percentage to read the other way round - from 100% -0% to 0% - 100%
var FindOne : float; // This gets EnemyAdding(remaining) and divides it by EnemyMax(total);
static var FindTotal : int; // This then multiplies it my 100 to make it a %.
function Update()
{
FindOne = EnemyAdding / EnemyMax;
FindTotal = FindOne * 100;
print(FindTotal);
}
If you want the percentage to read the opposite way round, then I replace EnemyAdding with EnemyRemaining.
The Destroy Enemy has:
EnemyRemaining --;
EnemyAdding ++;
I've answered something similar to this before here