I get a “Cannot implicitly convert ‘double’ to ‘float’. An explicit conversion exists (are you missing a cast?)” message for
the following formula to be used as argument in a Vector3:
float sph_x = Input.mousePosition.x/1280*7.7-3.85f; //sph_x would be 0,22859374999999900000
Surprisingly it works for this formula :
float sph_x = Input.mousePosition.x/1280*7-3.85f; //sph_x would be -0,14218750000000000000
I need only 2 or 3 decimals of precision.
Is there no conversion from double to float? I found only the Mathf.RoundToInt.
Not even if I multiply by 1000, Round to int and then divide back by 1000 doesn’t get a float:
float sph_y = ( Mathf.RoundToInt (1000* (Input.mousePosition.x/1280*7.65-3.85f) ) )/1000;
Now it gets 2 errors: the “cannot implicitly …” and another one “best overloaded method…”
Dividing an integer by 1000 results in 3 decimals ONLY so a float should be OK.
Only it isn’t.
There has to be a nice simple way to do this…
Thanks.