Search Unity

Number with comma

Discussion in 'Scripting' started by shuskry, May 25, 2017.

  1. shuskry

    shuskry

    Joined:
    Oct 10, 2015
    Posts:
    462
    Hi everybody, i'm trying do do a spawn manager for my 2d game and i want to use comma like this :

    new Vector2 ( 0, (1,5));

    How can i do ? unity said that it impossible to convert a double to float :/

    Thx for you're help ! :)
     
  2. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
    Standard decimal point denominator is a dot, not a comma.

    https://docs.unity3d.com/ScriptReference/Vector2-ctor.html

    So you should be using it as:
    Code (CSharp):
    1. new Vector2 ( 0 , 1.5 );
    And if double to float conversion is still causing you problems, add "f" at the end of each numerical value.
    Code (CSharp):
    1. new Vector2 ( 0.0f , 1.5f );
     
  3. shuskry

    shuskry

    Joined:
    Oct 10, 2015
    Posts:
    462
    Thank you ! :)