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 /
  • Help Room /
avatar image
0
Question by NerdRageStudios · Sep 14, 2015 at 02:06 PM · instantiatedestroy

Performance of instantiate and destroy for bullets

Hi all, I have read many threads here about pooling vs instantiate & destroy , but there doesn't seem to be a definitive answer.

I am working on a new game and before I get to the shooting system, I want to make sure my approach is good. I know that for mobile games, pooling objects is better for performance, but I am only developing for PC, Linux and Mac.

So, if you have machine guns firing bullets all over the place, should I simply create prefabs for the bullets and instaniate at the gun position and add force, using destroy when they collide with something?

I have tried this and it seems to work flawlessly, but then I do have a monster rig for my development machine.

What is the general consensus here? with todays modern PC's are you really going to see a hit in performance here? What if I call a GC regularly?

Or should I just stick to pooling objects instead (I can, but its a lot of extra work that I am not sure if its necessary).

Thanks for any advice

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 Kerihobo · Sep 14, 2015 at 02:39 PM 0
Share

Pooling is definitely better for performance. Don't take my advice though, personally I'd rather hear what someone from Infinite ward or Bungie have to say about that.

If it helps, I've resorted to using particles for my bullets, and I'm able to have 10s of thousands on my screen at once without any major performance concerns.

2 Replies

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

Answer by Suddoha · Sep 14, 2015 at 02:53 PM

Stick to object pooling.

In general, it's good to save performance wherever you can if it's not an overkill and too much effort for your project. Even though you may not recognize a drop in performance on your system, users may recognize it and as soon as your projects starts growing, there will be other things that may profit from the time you've saved there.

Basides that, object pooling allows to re-use the objects in an efficient way as you may know, you can control the amount of these objects (you can even use this in some ways to allow further tweaking on the user side via settings) and thus keep your scenes clean.

On top of that, it's a bit more professional and you can generalize the logic so that you don't even need to re-write everything.

Calling the GC manually is not a good idea at all as far as i can recall and may even cause noticeable "hiccups".

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 NerdRageStudios · Sep 14, 2015 at 03:29 PM 0
Share

Thanks for the input, its gives me some food for thought.

avatar image
1

Answer by Mr_Edward · Sep 14, 2015 at 03:23 PM

The performance hit isn't that bad, and it'll run fine on older machines. Especially when your CPU isn't overloaded with other calculations from the game. If you know that your game is going to be CPU intensive, implementing object pooling might still be a good idea though.

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

31 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

Related Questions

Bullet clones will not be destroyed. 2 Answers

How do I delete a specific prefab clone ? 0 Answers

Destroy prefabs after they have been instantiated (C#) 1 Answer

How do I destroy a GameObject/Script that instantiates other objects, without destroying the objects it has previously instantiated? 0 Answers

destroying instantiated groups of objects 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