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 jesus_the_jesus_man · Nov 23, 2014 at 04:17 PM · physics2dframeratetopdownrtsunits

Many units, best performance practices

Currently I am having a huge frame drop when I get about 300-400 units, What is the best practice to maintain a large amount of units (possibly 5000 and up is my target) in a simple top down RTS, according to the profiler the the biggest chunk of spent memory is in Physics2D.FixedUpdate and Unit.FixedUpdate

My units all have a RigidBody2D as well a circleCollider2D to handle collisions as well as not have them clump in together. but whenever I move them (the code inside FixedUpdate) my framerate goes to hell, any tips?

My game does have alot of times when units will be clumped together while moving through small choke points.

The following is what I assume is the main culprit, either the way I move the units, or the physics controlling them, the profiler states 60% towards unit.fixedupdate and 35% for physics2d.fixedupdate

 void FixedUpdate ()
 {
             if (Moving) {
                     tForm.position = Vector3.MoveTowards (tForm.position, PointB, this.Velocity * Time.deltaTime);
             }
 }
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 robertbu · Nov 23, 2014 at 04:18 PM 0
Share

I went ahead and published your question since someone might have a magic bullet, but in general design/discussion questions should be asked on Unity Forums. The format of Unity Answers is for single, specific technical questions.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AironeneroTechnologies · Nov 23, 2014 at 05:29 PM

You are using the unity standard navmesh pathfinding? Is really slow. Use a oyur custom algoritmh applied in a coroutine, that procedurally calculates the path step to step and not in 1 time. Also use of crowd movement to simplify calculation will help a lot.

In short: instead to make each unity calculate in only a short time all the path calculate in more steps for a group of units the path, this is the secret of massive RTS games like planetary annihilation or Supreme commander.

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 jesus_the_jesus_man · Nov 23, 2014 at 06:27 PM 0
Share

$$anonymous$$aybe I should have included my fixed update code to be more clear, all my fixedupdate does is move the unit, I updated my question with the code in question, so I guess I should rephrase it, how to properly move my unit? because I feel that it is either that or something involving physics.

avatar image
0

Answer by Kiwasi · Nov 23, 2014 at 11:32 PM

You could try using RigidBody2D.MovePosition instead.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

deltaTime doesn't work with custom gravity (ECS) 0 Answers

How to index objects 1 Answer

2D Platformer: Framerate causes inconsistency when falling off a platform. 0 Answers

RTS Movement and grid questions 0 Answers

Rootmotion only works on x-axis with dynamic Rigidbody2D 0 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