Search Unity

C# 2D, Changing a float on a Prefab in during while running.

Discussion in '2D' started by Blelon, Aug 4, 2019.

  1. Blelon

    Blelon

    Joined:
    Jul 13, 2019
    Posts:
    1
    I want to Change a float number on an Object before it gets Instantiated and I dont know how thats Possible so thats why i am here,

    I am making the Chrome offline trex game and am moving the ground, So i want to increase the speed over time, but the newly Instantiated Ground Objects still have the base speed, so my question is how i can change that.

    Thanks in Advance for Help^^
     
  2. Vryken

    Vryken

    Joined:
    Jan 23, 2018
    Posts:
    2,106
    You can change the value on the same frame the object is instantiated.
    Code (CSharp):
    1. GameObject foo = Instantiate(whatever);
    2. foo.floatValue = 10f;
     
    Deerkis and Blelon like this.