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 soco2211 · Mar 13, 2017 at 06:57 AM · unity 5

Advice on handling a large number of enemies on a large map

I'm making a jrpg style game, similar to the early Legend of Zelda games and was looking for some advice. The map is currently set up like a grid with 16 "rooms", each room containing about 5 enemies that wander between 5 waypoints in their respective room. All the rooms are an box collider blocking the exits so they are confined to their room. All the enemies are constantly active and wandering, running the same three scripts that handle their Health, Movement, and Attack. I am planning on expanding the map so I wanted to know if I'm approaching it the correct way before I get to far into it. Is it okay to have 50-100 or even up to 500 enemy gameobjects active or should I make them spawn and despawn when I cross a room border? Also, they all have rigidbody, capsule collider, nav mesh agent, and animator componants attached to them. As a sidenote, I constantly see tutorials and such on how to do stuff in Unity, but have yet to find a decent guide to planning/mapping out a game, if anyone has seen something like that, I'd be interested in reading it. Thanks for any advice.

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

Answer by Hanoble · Mar 13, 2017 at 07:44 AM

It all depends on so many questions that it is hard to tell you exactly when you have reached "the limit", but I would warn about early optimization. If you are going to mobile this could certainly be an issue, but before those scripts become a performance issue it is much more likely that the mobile GPUs would choke from the rendering without proper batching regardless. If you are on PC you might get away with it, but you might not... Depending on what your target specs are a slew of other issues could also be the real bottleneck, not your enemies.

In my opinion, what you are currently doing with your enemies is probably not going to kill performance on any decent hardware, but that definitely depends on your target platform. Having them spawned and enabling them on, or even running a very limited amount of the AI while the player is far away (depending on your game you could try actually enabling these components based off distance, what rooms are near others, etc) is probably better than instantiating these objects (as instantiation is very slow on some platforms). Once again though, there is almost never a 'one-size fits all' solution and depending on other factors your game might run perfectly fine instantiating all of your enemies.

In short, I would continue on developing your game and getting it to a point to where you can really ask yourself "is this fun and worth all the extra work it might take to get it to a point of actually releasing this for other people to play?". If that answer is yes, then profile your game with the Unity profiler, and ensure to do it on the target platforms. At that point you will be able to identify the real bottlenecks of your almost finished game, and be able to maximize your development time on things that make your game more fun.

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 soco2211 · Mar 13, 2017 at 11:01 PM 0
Share

Thanks for the reply, this is my first game with Unity and I'm really only planning on releasing it to my kids (8 and 12) for their computer so I never really gave any thought to the platform. I like your suggestion enabling them when the player is in a certain distance though, so I think I might start looking at that. Thanks again for your time.

avatar image
0

Answer by Kossuranta · Mar 13, 2017 at 07:49 AM

Answer little bit depends on how heavy your enemy objects are and what is target platform. However generally you can't have 500 active AI running around without killing performance and you have to activate/deactivate them depending on distance.

In most games where there are large amount of moving objects they are grouped because pathfinding is generally pretty heavy process.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to update apple watch content (from extension) with data from Unity project 1 Answer

UI interactions not working properly with Daydream 0 Answers

How do i create objects in between two points with an offset??? 1 Answer

Playing certain sound during collision 1 Answer

Changing shaders in a game during runtime 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