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. Dismiss Notice

random things like Snake

Discussion in 'Scripting' started by hadarartist, May 24, 2014.

  1. hadarartist

    hadarartist

    Joined:
    May 24, 2014
    Posts:
    1
    How to do like in Snake game that
    Appear things in the room like healing or Gold, randomly,
    after taking one, another appears somewhere else in the room,
    and with the option to change how often they appear?
     
  2. AlpacaMaster

    AlpacaMaster

    Joined:
    Jan 30, 2014
    Posts:
    32
    is it a 2D game or 3D?

    if it's 2D you can use instatiate:

    transform gold;
    gold = Instantiate(gold,vector2(random.range(0,10),random.range(0,10)) , quaternion(0,0)) as Transform;

    and then when you take it you change it's position:

    gold.position = new vector2(random.range(0,10),random.range(0,10));
     
  3. PerfectlyInsane

    PerfectlyInsane

    Joined:
    Aug 9, 2013
    Posts:
    74
    You would probably need to take into account grid size so your vector position would be a multiple of the gridsize. That is if you want to recreate the nokia snake experience.
     
    Last edited: May 25, 2014