Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

change variable in runtime

Discussion in 'Scripting' started by mrttis, Jul 2, 2015.

  1. mrttis

    mrttis

    Joined:
    Jul 12, 2012
    Posts:
    64
    Hi,

    My code must work for random variable in random time.
    or in other words I want change a random variable in runtime but It will change at end of every ten seconds(or in random time) ?
    i could not.

    How can i add random time for change variable in runtime?

    Code (JavaScript):
    1. #pragma strict
    2.  
    3.  
    4. public static var spdGrupOne = Random.Range(12,18);
    5.  
    6. function Start () {
    7.  
    8. }
    9.  
    10.  
    11. function Update () {
    12.  
    13.     Debug.Log(spdGrupOne);
    14.  
    15. }
    16.  
     
    Last edited: Jul 2, 2015
  2. mrttis

    mrttis

    Joined:
    Jul 12, 2012
    Posts:
    64
    Problem solved.
    thanks