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 Jezzah · Jun 11, 2013 at 07:17 PM · animationassetsloadingunloading

Best practice for loading unloading characters with animation.

Hi All,

I'm wondering what is the best practice for handling characters that most of the time are not needed in my game.

I have 4 separate areas, all of which have various animated characters. Do I disable them somehow when I leave that particular area or just leave them continuously animating and enabled in the scene.

I haven't notice much of a slow down yet, but I am planning to add quite a few more animated characters to my scene.

I want to avoid a possible pause and drop in frame rate as I enter a new area, given that the characters would be loaded into memory as I need them.

What approach do people mainly use?

Thanks

Jeremy

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

Answer by Yokimato · Jun 11, 2013 at 07:45 PM

I think the best approaches depend on if the characters need to be recalled after leaving an area, and if they do, how often?

You could, for example, call DestroyImmediate(someUnusedCharacter) after leaving the area if it's rare to have them recalled again. Once they return, you have to recreate the, again. However, if it's left up to the player (i.e the player decides always when and where they go) then I would simply disable them. What that does is saves you some computation. Unity already should be ignoring draw calls for meshs that are not visible by the camera. However, this can be expensive--setting them to disabled saves you a bit on that end. The downside though, is that they're still taking up memory so if you get really crazy with it, you might see performance degradation from that.

The other suggestion would be, depending on your game of course, would be to "pool" these resources and basically reuse them in each area. If character A looks the same as B, only they different in what you're calling 'areas', then you can simply reuse A to save creation cost and memory of holding both. This is more common with projectiles then actual characters of course, but I thought I'd throw it out there just in case it might work.

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
avatar image
0

Answer by TonyLi · Jun 11, 2013 at 07:52 PM

I recommend simplicity first. A finished product is better than an abandoned but well-optimized half-project. You may never need to optimize. Unity's default frustum culling only renders visible objects (details here). If you try to optimize early, you might even hurt framerate by paging stuff in and out.

Enabling and disabling shouldn't hurt, but the extra complexity might not be worth it. That said, I do it because my characters make a lot of AI checks. If you set up an area with a trigger collider and an array of characters inside the area, you can SetActive() the children appropriately whenever the player enters or exits the trigger.

If you're using Mecanim, it's pretty efficient, and you'll get memory savings, too, if you share animator controllers among multiple characters. If you're using legacy, profile it to see if there's any concern.

If you do need to load characters into memory, asynchronously pre-load your assets beforehand. Then when you instantiate characters it'll be fairly fast.

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

17 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

Related Questions

Prevent Unloading assets for Reloading scene for a second time! 1 Answer

How to prevent resources being unloaded unintentionally 0 Answers

Function deleting string by itself. 0 Answers

Animated GUI.DrawTexture while game is loading 0 Answers

Can I make animations snap to a frame? 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