BTW: the xposs is recieved from a server so i cant just say its a float, i need it converted to a float with 0.0f behind:
xposs = "951.9791"
xspawn = float.Parse(yposs);
this just returns 951.9791 in a float but i want 951.9791f
i have also tried:
xposs = "951.9791"
xspawn = float.Parse(yposs) + 0.0f;
this still does not work.
I need it to be 0.0f format becaouse i use it in a Vector3(), and not having the f does not seem to work (well it works but the cordinates are totally wrong, and if i manually press f after it works.)
f
postfix is applied only to literals in code. It is used to denote literal values asfloat
. If no postfix is present - literal value will be of typedouble
you can pass the result of
float.Parse(stringValue)
intoVector3
andVector2
as constructor arguments in Unity 3d The next code create a Vector3 object with x y z equal to value set in stringFloats are just a numeric value with type
System.Single
. They don't have anf
behind it. That's just the notation C# uses forfloat
literals.float.Parse
returns afloat
, it's not possible or necessary to add anf
.the "f" suffix is supplied in literal values to denote the data type