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 Rick74 · Mar 06, 2014 at 01:27 PM · javascriptarray

Array of enemies, first one in, last one out.

So yay! I finally built to my phone and I'm noticing a slight pause in the gameplay when their is a new wave of enemies spawned.

I know that it is from my instantiating them. So I need to change that into an array of enemy game object held off screen, and the spawner needs to pull from that array. However. How does that work?

I remember someone telling me about this "first one in, last one out" system. But I've done a search and so far I can't find even a mention of this system, let alone an example of how it works.

Can someone point me in the right direction?

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

2 Replies

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

Answer by haim96 · Mar 06, 2014 at 01:39 PM

what you are looking for is objects pool. in object pool you pre create the objects and then just enable them when you need them. when you done you disable them and they return to the pool.

here good article about this: http://www.gamasutra.com/blogs/WendelinReich/20131127/203843/C_Memory_Management_for_Unity_Developers_part_3_of_3.php

if you don't want to write your own there good few assets that will do the job.

since we posted almost the same answer at the same time i would like to add recommendation to product i'm working with that may help you:

https://www.assetstore.unity3d.com/#/content/6640

https://www.assetstore.unity3d.com/#/content/1010

:)

Comment
Add comment · Show 6 · 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 Rick74 · Mar 06, 2014 at 01:42 PM 0
Share

Thanks to both of you. Object pooling now rings a bell and I'll look into both those articles!

avatar image GameVortex · Mar 06, 2014 at 01:50 PM 0
Share

No problem =) Remember to tick one of us as the correct answer if we helped. @haim96 provided more and better links, so I recommend his answer. =)

avatar image Rick74 · Mar 06, 2014 at 02:39 PM 0
Share

You guys both helped me at roughly the same time, with roughly the same amount of help and set me on the path! So you two need to arm wrestle or flip a coin to see who gets it!

avatar image GameVortex · Mar 06, 2014 at 03:06 PM 0
Share

I pick Heads.

avatar image haim96 · Mar 06, 2014 at 03:18 PM 0
Share

Flip a coin for us. :)

Show more comments
avatar image
2

Answer by GameVortex · Mar 06, 2014 at 01:35 PM

You are looking for Pooling. The concept of pooling objects is to create them at the start and then keep them deactivated until needed. When finished with the object it is placed back in the pool. Here is good thread on it: http://forum.unity3d.com/threads/76851-Simple-Reusable-Object-Pool-Help-limit-your-instantiations!

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

22 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

Related Questions

Parse Array data to generate html 0 Answers

Why ExecuteInEditMode Always Causes NullReferenceException Errors Even In Clamping!! 2 Answers

TextAsset inside the Array - UnityScript/JavaScript 1 Answer

Sorting arrays? 1 Answer

How to delete new'd arrays? 2 Answers


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