Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Raijinn-sama · Dec 04, 2020 at 10:21 PM · unity 2dgame

more cubes if there are more rounds

hi I am at unity right now and I want to send out as many cubes as in a round, for example the first round a cube is sent and the fifth round five cubes have an idea how to do it but have a hard time starting

Anyone here who has time left and wants to help?

this is my first game in unity and im kinda lost XD

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sacredgeometry · Dec 04, 2020 at 10:32 PM 0
Share

I will try to interpret that but your question is a little ambiguous can you try to break it down into accurate instructions and a description of the outcome you are trying to achieve.


Is it that you are trying to create rounds of your game and each round needs to have a specific set of spawned objects?

2 Replies

· Add your reply
  • Sort: 
avatar image
-1

Answer by Llama_w_2Ls · Dec 05, 2020 at 10:24 AM

I believe that you want a difficulty-ramp-up type of game where more cubes spawn each round to make it harder to complete. Quite simply, if you're keeping track of what round you're on, you can use that value as the number of cubes to be instantiated in the next round.


I don't know how you're spawning your cubes, but I would write something like this:

     public class CubeSpawner : MonoBehaviour
     {
         public int CubesToSpawn = 1;
         public GameObject Cube;
         private List<GameObject> cubes = new List<GameObject>();
 
         void Start()
         {
             NextRound();
         }
 
         void Update()
         {
             if (cubes.Count == 0)
             {
                 NextRound();
             }
         }
 
         void NextRound()
         {
             for (int i = 0; i < CubesToSpawn; i++)
             {
                 // Instantiate 'Cube' 'i' amount of times
                 // cubes.Add('cube') adds to a list of how many cubes are left in the scene
                 // when destroyed, the cube is removed from the list.
             }
             CubesToSpawn++; // Spawns more cubes next round
         }
     }

@Raijinn-sama

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sacredgeometry · Dec 05, 2020 at 01:04 PM 0
Share

This wont work if you are using scenes and will mean that the round specification would be stuck to being unidirectional and procedural.

avatar image
0

Answer by Raijinn-sama · Dec 05, 2020 at 05:53 PM

Sorry okay I may need to add a little more clarity with my question. I'm trying to make a game where you are a cube in the middle of a plane and every round there are cubes from different directions What I am trying to do right now is to spawn cubes from different directions and that there will be as many cubes as the round that is shown, for example, if the round 5, there will be 5 cubes from different directions that you have to dodge

@Llama_w_2Ls @sacredgeometry

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Raijinn-sama · Dec 05, 2020 at 05:54 PM 0
Share

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class CubeSpawner : $$anonymous$$onoBehaviour { public GameObject [] spawnPoint; public GameObject spawnObject; private int spawnTotal = 2; public float timeBetweenSpawns; // Use this for initialization void Start() { spawnPoint = GameObject.FindGameObjectsWithTag("SpawnTag");

     StartCoroutine(SpawnGameObject());
 }

 // Update is called once per frame
 void Update()
 {
     // tryin to make the cubes rotate to the middle

    gameObject.transform.position += transform.forward * 1f *Time.deltaTime;
 }
 IEnumerator SpawnGameObject()
 {
     for (var x = 0; x < spawnPoint.Length; x++)
     {
         Instantiate(spawnObject, spawnPoint[x].transform.position, spawnPoint[x].transform.rotation);
         yield return new WaitForSeconds(timeBetweenSpawns);
     }
 }


   

}

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

183 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

My script only partially works 2 Answers

problem with building my game 1 Answer

Hi I am making a 2D game and I am having problem with this script: 1 Answer

making snake game but the code is confusing 1 Answer

how to develop a matching game based on a picture and a list of words? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges