this is the script :
distance++;
int help1 = int1/distance*size_of_the_object;
int1, distance and size_of_the_object are all ints
distance keeps coming out as zero and i don't know why.
i cheaked that distance couldn't be a negitve.
please help.
If distance was 0, that line would be crashing with a divide by zero error.
How do you know that distance is 0? Have you placed a line like this before and after the "distance++" line?
Display("distance = %d", distance);
int help1 = int1/distance*size_of_the_object;
distance keeps coming out as zero and i don't know why.
I do know why.
int help1 = int1/distance*size_of_the_object;
First which math should happen first?
this?
int help1 = (int1/distance)*size_of_the_object;
or this:
int help1 = int1/(distance*size_of_the_object);
Thanks both of you I will try this and see if it works ;D
you can also set distance initial value to 1
int distance=1;
Thanks but the distance is calculated by the players pos and the object pos
There's a probability(i'm just guessing) that the distance integer doesn't get a value before the if statement.
Thanks but I have managed to fix Ito