- Home /
Problem is not reproducible or outdated
Multiply by float (Double, Decimal)
Hi,
I'm trying to be more specific with a level multiplier, if I multiply a float by a float it just ends up counting to infinity as soon as an event takes place. You can't multiply by double or decimal, cant use an int, so what can I do about it?
Thanks in advance.
(Update: Code as requested)
private float levMult = 1.4f;
// Use this for initialization
void Start () {
}
void Update () {
// Just a test to see if it works...
if (Input.GetMouseButtonDown(0)){
currentExperience = currentExperience + 1000;
}
if (Health == 0){
animation.CrossFade("die");
Application.LoadLevel(0);
}
if (currentExperience >= maxExperience){
LevelUp();
}
}
void LevelUp () {
maxExperience = maxExperience * levMult;
Level ++;
statPoints = 5;
}
}
what?! what do you mean by "level multiplier", "counting to infinity", "an event takes place"? Please post code that demonstrates whatever problem you are having.
Please give us the starting value of maxExperience, as well as the type of that variable. You're being very unspecific here, and it's making your question very hard to answer - we need to know the context, we aren't $$anonymous$$d-readers.
Yeah apologies, it's working now and I couldn't tell you why. Odd, anyway thanks for taking the time..