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 /
  • Help Room /
avatar image
0
Question by tbm007 · Jan 28, 2017 at 05:44 PM · rotationtransformrigidbody physics

Determine object's tipping point.

Hi all,

Unity noob here, with a question that seems like it should have a simple answer. I'd like to determine the tipping point of an object (rigidbody). Take a cube at rest on a plane, and apply a torque to it around the X or Z axis. At some point (the TP) it will tip over - this happens in real life when the center of mass of an object falls outside its base. I'd like to know the specific moment this happens, for arbitrary objects.

I've tried messing with transform.up and friends, but it seems like I'd have to calculate a specific threshold of 'tippiness' for any given object in advance. Quite clearly the physics engine knows when an object tips over, so it seems reasonable enough to expect to be able to retrieve the information.

Methods attempted:

  1. Compare transform.up to Vector3.up. If some threshold exceeded, the object is tipped. Works, but has to be tweaked for different objects in advance. I'd like to be able to calculate on a per-frame basis (e.g. in Update())

  2. Similarly, compare angular velocity against some threshold. This had less than satisfying results, since an object can wobble considerably before finally settling back to its original position.

  3. Retrieve the object's renderer bounds, and attempt to determine if the X or Z coordinate of the center of mass differs from those of the base (the corner coordinates, in the case of a cube). This involved a lot of vector3 math, leading me to believe I'm on the wrong path, and also doesn't work in any case since the bounds of an object are axis-aligned to the world and always contain the object's center of mass (unless CoM is tweaked to be "outside the object" - but that would not be realistic) . Even if it worked for a cube, it seems unlikely to work for any given arbitrary structure.

  4. Calculate a non-AABB bounding box based on the transform's position and rotation, and apply vector math similarly to 3. Again, seems like a lot of work for something that should be exposed in an API* somewhere, and also would be hard to achieve consistent results across arbitrary structures.

*Ideally, something like transform.bounds.Contains(rigidbody.centerOfMass.position)

So what am I missing?

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 tbm007 · Jan 29, 2017 at 01:55 AM 0
Share

I've also added method 5:

  • Raycast from the C-of-$$anonymous$$ vertically down ( -Vector3.up ) and see if this intersects the base of the object. This seems to be the most promising approach so far, although I have no idea how to deter$$anonymous$$e if such a ray passes through the base. Can't use a bounding box approach for the reasons above, and there doesn't see to be an ArbitraryGeometry.IntersectRay() method anywhere.

0 Replies

· Add your reply
  • Sort: 

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why is this code in the script not stopping the rotation of the Gameobject? 0 Answers

How do you rotate the player and keep them there? 1 Answer

im trying to make my mini gun rotate up and down more than >0degree and less than <30degree, can anyone help me please?thanks! 0 Answers

How to translate an object in an unknown angle ? 1 Answer

Rigidbody AddForce doesn't matter what rotation 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