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

How can I make a "cube" generator?

Discussion in 'Scripting' started by unity_svRK4vrJhVF5Gg, Feb 10, 2020.

  1. unity_svRK4vrJhVF5Gg

    unity_svRK4vrJhVF5Gg

    Joined:
    Feb 3, 2020
    Posts:
    3
    Hi, I have some experience coding I just need a bit of help to get started.
    How could I code a "cube" dropper? A cube dropper that drops a cube at some interval from some distance on the positive y-axis?

    Sorta like this picture.


    upload_2020-2-9_21-33-44.png
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,594
    It is very basics. To understand what you need to know, you should follow Getting Started forum
    https://forum.unity.com/forums/getting-started.82/
     
  3. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    I recommend you look up how to create Prefabs and then use Object.Instantiate in your script to create them. To make the objects drop in intervals, an easy method involves applying InvokeRepeating to your spawing method.
     
    Ryiah likes this.
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,594
    That solution is fine, as long OP is aware, how and when to stop spawning. And if need to destroy Game Objects (go).

    Possibly a bit more complex solution, is to build pooling system.
     
  5. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
  6. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    1,556
    konsic likes this.
  7. unity_svRK4vrJhVF5Gg

    unity_svRK4vrJhVF5Gg

    Joined:
    Feb 3, 2020
    Posts:
    3