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 lightnarcissus · Sep 12, 2013 at 01:13 PM · objectoptimizationgenerationdynamic batchinginstantiating

Ideal Dynamic Object Generation Technique

I am making a game which would require objects (or civilians specifically) which would need to be generated around player.

Currently, I am using a custom system where I am spawning them randomly around the player as he walks upto a certain number. The civilians (non-important ones) are destroyed once the distance between them and the player goes beyond a certain limit. For that, I have every civilian object occasionally check the distance between itself and the player. The number of civilians is somewhere around 100-120. The issue is it can be something of a performance hog.

There is also an occasional problem where if I keep the "maximum distance" between player and civilian before it gets destroyed too large, I run into empty sections of the city.

What I want to ask is that is there a better dynamic object generation that can deal with both the above mentioned issues.

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 meat5000 ♦ · Sep 12, 2013 at 01:18 PM 0
Share

Can you teleport the civilians, hence recycling them, ins$$anonymous$$d of destroy->instantiate?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Doeko · Sep 12, 2013 at 01:59 PM

You don't want to dynamically generate objects at all, because destroying and instantiating is very slow especially if you have 100+ objects. Create a pool of Civilian objects which you re-use. So when a certain civilian goes out of range, you teleport it somewhere in the vicinity of the player when appropriate, instead of destroying it and instantiating a new one.

For further performance increases you may want to group civilians so that groups of 5-10 never wander too far from each other, and check the distance to the player as a group instead of individually.

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

17 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

Related Questions

Most performance friendly way to "unrender" a GameObject? 6 Answers

Object pulling prefabs that are randomly generating between random points? 0 Answers

(c# source request) how to spawn a few bottom objects in a spiral to create a simple terrain? 1 Answer

Object.get_name() performance 0 Answers

Dynamic Batching performance for mobile 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