Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Jeffruddick · Oct 24, 2019 at 11:27 AM · gameobjectprefabscpu usage

Large Volume of Game Objects - is there another way?

I thought it would be fun to build a visual compound interest calculator in Unity. The goal is to allow kids to visualize the power of compound interest via the accumulation of $10,000 "straps" or "bands". It is a pretty simple concept; as the years progress, the pile of money gets larger. The code below works but generates a random pile of cubes (stand-in) for the money bands. This is generating thousands of game objects and is putting strain on the CPU. This will not work for my plan of running this visualization in mobile AR.

I'm new to Unity but I wonder if it would be best to group game objects and maybe forgo some of the physics calculations? A vertical stack of 20 or so wide would make for better visualization so maybe create game objects for the items on top and then extend the bottom rows vs. creating new game objects? Any ideas or suggestions would be appreciated.

Jeff

     IEnumerator Loop()
     {
         instanceCount = accumulated / 10000;  //get's 10K stacks!
         yearAccumulated = instanceCount - iCounter;  //designed to get the incremental value per year 
         yearAccumulated = (Mathf.Floor(yearAccumulated));  //Changed from Mathf.Round as this rounds up and I it to round down.   
         Debug.Log(yearAccumulated.ToString());
         //Debug.Log(instanceCount.ToString());
 
         for (int i = 0; i < yearAccumulated; i++)
         {
             Vector3 position = new Vector3(Random.Range(-3.0f, 3.0f), 3, Random.Range(-3.0f, 3.0f));  //creates stacks in random range
                 Instantiate(prefab, position, Quaternion.identity);
                 iCounter++;  //increments loop counter
                 Debug.Log(iCounter.ToString());
             yield return null;
         }
 
     }
 
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 Pangamini · Oct 24, 2019 at 04:59 PM 0
Share

Can't you just stretch a single cube? Perhaps a picture of desired result would be in place here

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Strixie13 · Oct 24, 2019 at 04:59 PM

You would have to find a way to bring the object count down. Mobile is super limited so any solution would involve a small object count and minimal physics. Object count is medium-expensive, and physics calculations are super-expensive. Not too familiar with AR, but I think it is even more strenuous on the device for computation?


For your specific example I would have maybe 3 bands with full physics enabled, and then every time the number of bands gets to X large number, add model of a stack of cash (using a box model with a texture). Those could also have physics enabled, and since box colliers are pretty cheap you could have maybe 20-30 of them in the room? That gives you the ability to interact with the environment, you get the feeling that the room is full of stuff, and will not blow up your device :)

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 Jeffruddick · Oct 25, 2019 at 03:00 AM 0
Share

Thank you for the suggestion. I like the idea as I could scale the models exponentially along with the numbers. This should keep the game object count to a much more reasonable number.

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

180 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

Related Questions

Create with code 2.2 pizza not shooting 1 Answer

How to tell at runtime if a GameObject is a prefab 3 Answers

how to get the prefab path of a game object in Game mode,not Editor mode 1 Answer

Prefab doesn't keep it's public variable when Instantiated? 2 Answers

Getting MouseEnter to Another Object 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