Search Unity

component

Discussion in 'Scripting' started by AlbertoT, Apr 10, 2009.

  1. AlbertoT

    AlbertoT

    Joined:
    Mar 27, 2009
    Posts:
    159
    Hello

    I am learning Unity scripting language in these days
    A question

    Suppose that I create a component, let's call it
    "Action "
    My "Action " depends on a set of input parameters as well as by a random number which is generated ,at time intervals , by a function which belong to the component

    I attach this component to several GameObject

    Does each GameObject generate its own random number ?

    In other words can I expect that each GameObject perform a slightly different action, given the same set of input parameters ?

    Thanks in advance
     
  2. SimonAlkemade

    SimonAlkemade

    Joined:
    Feb 4, 2009
    Posts:
    432
    yes but you might want to re-seed range function or value variabele.
     
  3. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    Yes, using Unity's standard random number features, each object will behave in a unique way.

    You shouldn't reseed the random number generator unless you specifically want to cause a particular sequence of numbers to come out of it. Reseeding frequently according to the current time is likely to make your numbers less random.