RenderText
Moderator: Moderators
RenderText
How FloatMultiply operates remains mystery. I set up this for testing.
- Attachments
-
- rendTextNum.zgeproj
- (491 Bytes) Downloaded 451 times

Never used it like that myself .. only to multiply by 10 / 100 / 1000 etc.
Anyway, the RenderText component only displays the part of a float that is in front of the decimal ( so the behavior is similar to when you'd truncate a float to a integer ).
2*0.49 = 0.98
2*0.50 = 1.00
2*0.51 = 1.02
Also, you don't have to put the "n=2.0" assignment in the OnUpdate event since the RenderText component doesn't actually apply the multiplication to the variable ( uses a internal variable / property instead ). Neither do you have to write "2.0" .. just "2" is sufficient ( unlike for GLSL ).
K

Function for converting a float to a string ( including decimal separator ). First argument is the float, second is the number of fractions you want to show.
Code: Select all
string floatToStr(float X, int N)
{
string F, S;
if(X < 0)S = "-"; else S = "+";
float P = pow(10,N);
F = intToStr(floor(abs(frac(X)*P)));
while(length(F) < N)F = "0"+F;
return S+intToStr(abs(X))+"."+F;
}