• 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
4
Question by kromenak · Jul 06, 2011 at 01:23 AM · collisionphysicsweight

Strategies for creating a physics weight system.

Hey guys,

I'm working on a project where a number of objects have a weight value that I define, as well as a value that indicates the maximum weight the object can sustain. Using the physics engine, I'm trying to make a system where stacked objects impart their weight values onto the objects below them and if the objects below exceed their maximum weight values, the objects break. Additionally, if an object is placed on top of a stack of objects, it applies its weight to the one below it, which in turn applies the combined weight to the one below it, and so on.

Additionally, I'm trying to support the ability to distribute weight amongst more than one object below. For example, if I place an object on top of two other objects, it imparts half of its weight to each of the two objects rather than all of it to one.

As you might guess, I'm having a lot of trouble getting this to work correctly given the available OnCollision functions and whatnot. I'm wondering if anyone has any thoughts on how they'd implement such a system, or whether the physics system has some built-in elements I can be using for this. This is an iphone game, so I'm also trying to decide what is most performance-savvy.

I feel pretty stuck on this, so any thoughts or suggestions would be extremely welcomed and appreciated.

Thanks :)

Comment
Add comment · Show 2
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 aldonaletto · Jul 06, 2011 at 06:41 PM 0
Share

How are the objects you want to use? Cubes or bricks, or more complex objects? And how do you think to place the objects? Do you want to let them fall freely over the others, or will them be positioned without impact? The easiest case would be rectangular shaped objects placed gently over the others (if you let a rigidbody fall freely, it will bounce and rotate, and may end in unpredictable positions).

avatar image Waz · Jul 06, 2011 at 09:57 PM 0
Share

I agree with aldonaletto - unless you've got simplified objects, you're asking for something that the physics system doesn't have so it will be a lot of work to implement.

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by Waz · Jul 06, 2011 at 10:06 PM

For complex object, I imagine you will need to maintain the set of contact points, take note of the Normals in order to infer which object is pressing down on which others, the distance of the contact point from the centre of mass to bias the weight distribution by, and finally sum up the hierarchy of inferred stacking whenever the contact points change. How realistic the results will be is hard to tell since it's just a heuristic approach. I used similar fakery once to make objects float and while it was good enough for "game physics", it didn't really look true to the real world. If this mechanic is key to your player's success, they may get frustrated if it is too far from reality.

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 kromenak · Jul 06, 2011 at 11:25 PM 0
Share

Thanks for your comments! Did you ever find a good way to maintain contact points given by OnCollisionEnter? Do those collision points ever become "stale"?

Some behavior I have noticed is that if you begin a collision on the side of an object and carefully move the object to the top, it does not register a new collision event - which could mean that my original contact points are now incorrect. Or do the contact points update over the lifetime of the contact???

avatar image Waz · Jul 06, 2011 at 11:33 PM 0
Share

No, in the end I used OnCollisionStay which was pretty wasteful. I've not looked into it for a while though so it may even have been fixed in Unity 3, if it was indeed a bug. Though from what your saying in this comment, it is still a problem.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

unity3d is meter units? meter to cm 1 Answer

I want my Player to have collision physics 1 Answer

How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer

Moving a ball around a maze 3 Answers

Keep rotation when changing parent in Unity 3D 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