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 MadboyJames · Jul 25, 2019 at 03:54 PM · c#collision detectionperformance optimizationpooling

Best performance for mass object movement

I found myself doing some research before making a gun system in unity 2D ( Essentially a "rapid spawn object" system that I can make into whatever with a few extra behaviors), and I came across a couple threads which raised me some questions in terms of mass performance (I expect a maximum of 500 bullet objects on the screen at once, if the player works to "group enemies" with aggro in a way that I would not intend, ie. this should not be a bullet hell, but could be if the player is trying to break the game)
[]
What I'm wondering is "What is the best practice for scaling mass object movement?"
[]
I know of object pooling, and intend to use it. But I found this in regard to enabling objects here: https://forum.unity.com/threads/bullet-hell-without-performance-hit.568243/ where Brownboot67 said "Enable and disable are very slow. Just move the bullets very far away when you don't need them."
if this is true (and I see no reason why its not) then I would make a "DisabledObj" region off-map, which would have aMyDisabledObjManager script with a Dictionary of obj & bool, called disabledObjs. Then OnCollisionStay it would compare objects in region to the objs in dictionary, and if there was a new obj then it would add it to the dictionary and do obj.GetComponent().myIsActiveBool=false; In every gameobject in the region, in update, if (myIsActiveBool==false){return}; I could have the bullet remove itself from the dictionary when it gets reused if I make the MyDisabledObjManager scrip (which has the dictionary) a singleton, which every object that can be MyDisabled() has a reference to.
Is this a viable solution? Is there a "best practice" for object pooling without enabling and disabling gameobject? Is it even necessary?

[]
Another performance question arises due to collision. Rigidbodies are expensive, so as few objects as possible should have them. Does this mean that collision detection between a bullet and a wall/enemy/player is determined entirely by the object being hit, and none by the bullet itself? (aside from range in regard to timeout, but that's not collision). Is there a better way to handle collision detection than putting a Kinematic/ static Rigidbody on the root terrain itself? Is it actually a good practice to do that?

[]
Any insight, thoughts, and experience shared will be appreciated.

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
1
Best Answer

Answer by Arpi01 · Jul 25, 2019 at 11:33 PM

I think you should look into ECS, it was made for that kind of situations

Comment
Add comment · Show 4 · 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 MadboyJames · Jul 26, 2019 at 03:49 PM 0
Share

Seems promising. I'll look into it, I haven't heard of ECS before now. Thanks!

avatar image xxmariofer MadboyJames · Jul 26, 2019 at 05:35 PM 0
Share

I once done something similar, and changing from gameobject bullets to a particle system performance benefit was really really big. follow this simple tutorial and you will be able to do it without any performance issue

https://unity3d.com/es/learn/tutorials/topics/scripting/particle-collisions

avatar image Captain_Pineapple MadboyJames · Jul 26, 2019 at 06:22 PM 0
Share

Do what @xxmariofer proposed first, ecs is nice but difficult to learn. Good in-depth documentation is rare, any information older than half a year most likely outdated. there were a lot of API changes in the last year.

avatar image MadboyJames Captain_Pineapple · Jul 29, 2019 at 03:26 PM 0
Share

I looked a bit into ECS and I think I will try to learn it for future projects, but for right now, using the particle system should fit my needs.

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

114 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

Related Questions

Distribute terrain in zones 3 Answers

Multiple Cars not working 1 Answer

Component.GetComponent() very slow 0 Answers

Using raycast for visible bullet collision (not oncollisionenter) in C# 1 Answer

How do I destroy a game object my character hit ONLY if a condition is active? 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