Search Unity

Change Float thru script?

Discussion in 'Scripting' started by ThatOneCake, Mar 20, 2019.

  1. ThatOneCake

    ThatOneCake

    Joined:
    Dec 2, 2018
    Posts:
    36
    Hey iam working on a game jam right now and i wonder if i can change a float value in my script and i cant find annything online thank you.
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,769
    What you mean by change?

    If you know how to set and read values from string, int, bool etc, you know already how to set float.
    If you don't, you need back to basics.
     
    SparrowGS and ThatOneCake like this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Code (csharp):
    1. float myFloat = 1.5f;
    2. myFloat = 7.6f;  //value of myFloat is now changed to 7.6
    3. myFloat += 1.1f  //value of myFloat is now changed to approximately 8.7
     
    Antypodish and ThatOneCake like this.
  4. ThatOneCake

    ThatOneCake

    Joined:
    Dec 2, 2018
    Posts:
    36
    yeah but do you know how to do that
     
  5. ThatOneCake

    ThatOneCake

    Joined:
    Dec 2, 2018
    Posts:
    36
    thank you so much
     
  6. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    I dont think doing a game jam is the best thing to do right now if you still need help with stuff like that.

    Not trying to diss you, none of us was born with the know-hows, but can't hold the hammer right, let alone build a shed, spend some more time learning(books and tuts) pure c#.
     
    Joe-Censored and Antypodish like this.
  7. ThatOneCake

    ThatOneCake

    Joined:
    Dec 2, 2018
    Posts:
    36
    yeah good idea
     
    Joe-Censored likes this.