• 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 studentvz · Jul 09, 2015 at 07:52 AM · rigidbodyboxcollider

Adding cargo to truck makes game not fluid as before

Hi,

I'm building a cargo truck game. I have terrain and a truck and everything is great. But when I add cargo (box with rigidbody and box collider) on truck cargo space I can see some hard noticable stutterin of terrain when I drive and make a turn. Simply I can see that game is not fluid as before. Cargo is lowpoly, takes 1 draw call and 100 tris / 100 verts, interpolate is on.

Did anyone experiance this before?

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

Answer by AlwaysSunny · Jul 09, 2015 at 07:52 AM

"hard noticable stutterin of terrain when I drive and make a turn"

You lost me with "of terrain". What does that mean? Anyway, generic advice is:

Non-kinematic bodies act on one another. In a "stack" or "basket" type situation, which is what I imagine you're describing, this can manifest as a shuttering / stuttering behavior, especially when the basket / platform is also mobile. You aren't making the rigidbody packages children of the rigidbody vehicle, right? Because that would be bad.

If you've already tuned the masses, frictions, and bounce factors of your objects to the most realistic figures possible, but you still encounter this problem, the next thing that comes to mind is using a proxy to bypass the problem.

You could move the "packages" to a separate physics layer which collides only with a proxy layer. The bed or box of your vehicle gets an extra kinematic rigidbody collider that exists on this proxy layer. It should have the same size and shape of the actual container. (5-6 box colliders is probably better than a mesh collider for this purpose)

The proxy container object gets its position / rotation from the actual container/vehicle object each frame, but the actual container/vehicle no longer collides with the packages.

Thus the packages will appear to move and respond to the movement of the true container, but the packages will not affect the container/vehicle.

Give this a try and see if it corrects the problem.

Best,

Comment
Add comment · Show 2 · 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 studentvz · Jul 17, 2015 at 03:04 PM 0
Share

Sorry for my late response. I was testing my game to find real issue. I'm developing for android.

It seams that this is not my problem, as I found my main problem is overdraw and 2-3 scripts (but they are very simple and because of that I don't know why the have some impact on performance). One have counter in Update and also fetching one bool variable from another script on same object. Beside that it has OnTriggerEnter where I check for 2 tag's. Another script is attached to terrain and it is detecting if Cargo touched terrain - OnCollisionEnter.

I'm tesing on LG G3, this phone overheats very quckly (what is maybe good to see worst scenario). So, after 5-10$$anonymous$$ of playing some hardly noticable stuttering appers on some parts of my terrain. This happens when my fps drops below lets say 55fps for few frames.

I also tryed to limit FPS to 30, 45 and 50 but then games stutters alot, it is not fluid as before. It is ugly. But, sometimes without any fps limit I can see that my FPS gets locked to 50 by game itself or phone, and then it is fluid and playable like on 60 FPS.

$$anonymous$$y stats: 30-45 Draw Calls 15-22 Tris 13-20 Verts

avatar image AlwaysSunny · Jul 17, 2015 at 07:17 PM 0
Share

Overdraw may be difficult to mitigate. $$anonymous$$ost of the other things you mentioned can be fixed or improved upon.

Perhaps the most essential optimization to consider may be choosing to use fewer drawn and fewer physically-interactive objects. You don't talk about how many bodies are interacting in this scenario, but more than "a few" would exacerbate any outstanding issues.

Consider possible optimizations you could make without sacrificing gameplay mechanics:

"One have counter in Update and also fetching one bool variable from another script on same object" - Reducing code inside Update methods is always wise; can either of these things happen fewer than once per frame? Consider moving nonessential per-frame code into a coroutine that executes, e.g. every other frame, or every 0.05 seconds.

"Beside that it has OnTriggerEnter where I check for 2 tag's." Checking for tags is expensive. It is cheaper to check almost anything else, such as checking the layer by index, or the presence of a particular component. Reducing string checks is a "first stage" optimization in any project.

Because you're talking about bad things happening after 5-10 $$anonymous$$utes, I wonder if you might have some garbage collection (memory leak) or other type of accumulation problem. Does the problem persist if you quit and immediately restart the game while the phone is still running hot?

Best,

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Collision Detection for Kinematic Rigidbodies 0 Answers

Box collider won't collide as a child? 0 Answers

how do you activate a sound effect when two objects with box colliders hit? 0 Answers

Ridgidbody cube 1 Answer

CharacterController and Normal rigidbody Box Collider Collision issues 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