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 boddole · Mar 21, 2014 at 04:56 AM · c#physicsrigidbodyios

Performance Question on Kinematic Rigidbodies

Hello everyone, I've been doing some on device testing (in my case an iPhone 4) using the free Unity profiler and default Unity physics settings, and noticed that in a particular scene physx is taking around 40-60ms to render about 30-40 objects that are kinematic rigidbodies controlled through scripts (use no real physics).

More details: -The scene in question is a "frogger" type setup, where rocks move along a straight path and bob up and down (all according to script), and when a player stands on them, they begin to sink.

Each rock has a mesh collider and a mesh trigger.

The primary script methods used to move these rocks are Vector3.Slerp, Vector3.MoveTowards, and Vector3.Distance.

I have been reading around and apparently for the number of objects on screen, this is a very significant amount of time spend on physx. So, I was wondering what the best to way go about cleaning this up is? Changing physics settings? Different object setup? Different script methods? Any help is appreciated.

I should also mention that at this point, for convenience these rocks are instantiated and destroyed (not recycled) and the garbage collector tops out at around 5.

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 Hoeloe · Mar 21, 2014 at 10:28 AM 1
Share

Just a point of detail - PhysX doesn't do rendering. It's solely for physics calculations. Rendering is done separately. But, as has been said, it's $$anonymous$$eshColliders that are causing the problem - they are very expensive. It's best, where at all possible, to approximate them by one or more primitive colliders.

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by pako · Mar 21, 2014 at 10:20 AM

Mesh colliders are very expensive for performance. So, this where I would start. Try to approximate the rock shape with another collider, e.g. capsule.

Also, you should really use some pooling method to recycle the rocks, because the GC kicking in at any point in the game, could make the game freeze for a couple of seconds or so.

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 boddole · Mar 21, 2014 at 06:04 PM 0
Share

Fair enough, I made some adjustments earlier today:

-Removing the mesh trigger and using on Collision ins$$anonymous$$d of ontrigger saved about 50% performance vs the old setup

-Changed fixed timestamp from 0.02 to 0.04 and that also saved about 50% performance vs the old setup

So really, just those 2 changed together probably would be enough, but I'll work on pooling next.

By the way, does the GC cause freezes even if the profiler is showing $$anonymous$$imal GC times?

avatar image Dblfstr · Mar 21, 2014 at 06:20 PM 0
Share

The GC will cause freezes even when the profiler shows $$anonymous$$imal GC times. Because the GC is ran whenever it feels like it needs to, and when it does, you will see the framerate drop.

avatar image boddole · Mar 21, 2014 at 06:45 PM 0
Share

I see, thanks.

avatar image pako · Mar 21, 2014 at 06:51 PM 0
Share

I can't give a black/white yes/no answer to your GC question. I can only tell you my opinion. I think that the GC times shown in the profiler should be used just as an indication. The GC is a dynamic process, as its frequency depends on the size of the heap, which gets adjusted all the time. So, I believe that a low indication for GC in the profiler, cannot guarantee to me that under some different conditions in the same game, the GC won't freeze the game for a couple of seconds.

Of course, the target devices is a very important issue. Since you are targeting iOS, you have very few target devices to consider and test. But if you target Android, which has over 11,000 different devices, would you trust that the low figure for GC that the profiler gives, would not -momentarily- freeze the game in a low/medium end Android device?

So, as a matter of good practice, I use object pooling all the time,especially in games where objects get created and destroyed with high frequency.

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

23 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Force to Velocity scaling? 2 Answers

RigidBody Script Conflict 1 Answer

How to create a damped harmonic oscillation? 1 Answer

Problem Trying to Apply Non-Kinematic Velocity to Rigidbody 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