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 iwe12 · Sep 04, 2014 at 07:00 AM · scenegame over

Final scene like a puzzle

Hello everyone :)

I'm creating a game where player collecting objects - balls - C#.

How could i make a final scene with some kind a puzzle statistics?

On the end of the game one big ball is filling up with small balls, and number of small balls is equal with number of collected balls during the game.

Thanks in advance :)

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Wiki

Answer by NvGBoink · Sep 04, 2014 at 08:34 PM

 using UnityEngine;
 using System.Collections;
 
 public class Balls : MonoBehaviour {
 
     //Number of balls is a static variable to allow you to edit from another script.
     //Use Balls.numberOfBalls in another script to change it.
     static public int numberOfBalls = 10;
 
     //This game object will represent the balls faling into the big ball.
     public GameObject ball;
 
     // Use this for initialization
     void Start () {
 
         //A for loop will basically count a unknown number for you. The first part of the for loop defines a variable for you, i stands for index, 
         //The next part is the requirements for the loop to meet in order to continue, the third part "i++" is what happens if the loops requirements is met. 
         //This counts the number of balls you have collected and will run the instantiate that many times.
         for(int i = 0; i <= numberOfBalls; i++){
             Instantiate(ball, new Vector3 (0, gameObject.transform.position.y + i ,0), Quaternion.identity);
         }
     }
 }
 
 //Sorry if I havn't explained it well.

As explained badly in the code's comments all you have to do to make this work is make a new script called Balls, add it to an empty game object that represents the position that you want the balls to start at. As long as you edit the numberOfBalls variable to be equal to the amount of balls you have collected in any of your scripts that counts them it should work.

Please let me know if you have any questions about this. Some tips for posting questions in the future, let people know what language your using, I hope your using C# but if not I can change it to JS, secondly post what code you have related to the problem, it can speed things up tremendously. Good luck with your game.

Comment
Add comment · 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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How do I make a scene change when my Player collides with a item? 1 Answer

iOS crashing between scenes, memory problem? 0 Answers

Restarting scene not working properly 1 Answer

terrain wont come up in scene 0 Answers

How to build scene like this? 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