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 hyperi0n · May 29, 2019 at 07:38 AM · rtsstatsunits

Storing Unit Stats - Best Practices?

Hi guys, I have a quick question for you :) I'm working on a little RTS prototype and was wondering if the following has any impact on performance (especially with higher unit counts):

Let's take a simple stat like the "AttackDamage" that a unit deals. Units are built off the templates of unit classes (eg Swordsman, Spearman, Knight...). Say, for example the AttackDamage of the Swordsman Class is 5.

So my question is: would it be better - at runtime - to copy the 5 into a script of each individual instance of the swordsman unit on the map when it is spawned. Then, whenever a specific unit attacks, it looks up the attack damage stored in its attached UnitStats script...

...OR is it better to have the unit remember ONLY which class it belongs to and then reference the UnitClassStats script of the parent class?

So the way I see it with my limited understanding of these things is: it's a trade off between storing more data (a copy of the value in each individual unit) vs. a slightly more complex reference (to the unit class script) - is that correct? Does this even make any difference? Are there best practices?

Thanks in advance! :)

P.S. Of course there could be additional factors like upgrades or temporary buffs which probably would have to be sorted out on a per-unit basis.

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

Answer by Pangamini · May 29, 2019 at 07:45 AM

Performance wise, don't worry about it. There sure are many other factors, such as cpu cache, but seriously, don't worry about it. It won't ever be enough to make a measurable diffence in a game (you might consider micro-optimizing like this when you are writing a high-performance engine part, or something). Especially when you are PROTOTYPING.

Think about what is easier for you, in the terms of balancing or other future features. I prefer to create a UnitType object somewhere in the asset database and just assign that - just so I can tweak units globally and don't have to worry about level designers overriding prefab values - but that exactly same reason can also be a drawback (you might want the level designer to instantiate a slightly modified unit).

In conclusion, don't worry about performace and do what's more practical, and in a prototype, what's faster to do

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 hyperi0n · May 29, 2019 at 07:52 AM 0
Share

Ok, that sounds great. Thanks! :)

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

108 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

Related Questions

Most efficient way to create an AI's view? 0 Answers

rts developement 0 Answers

Unity RayCast Selection 1 Answer

RTS Unit Creation Bar Queue System 1 Answer

Many units, best performance practices 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