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 /
avatar image
0
Question by Dytdyt · Feb 02, 2017 at 03:23 PM · physicsbikebalance

Rigidbody keep balance

I've been trying to figure out a way to balance a rigidbody at an certain angle. What i have is a rigidbody standing up, and i want it to balance at an angle "theta" which i can control: alt text So i want to make theta equal to 0, like this: alt text

It's important that it's done by the physics engine, but i can't figure out how to do. I've tried messing around with the center of mass but never succeded. Any ideas? Thanks :)

1.png (5.1 kB)
2.png (5.8 kB)
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
2

Answer by ZannaU · Feb 02, 2017 at 10:36 PM

From your explanation it's not very clear what is your objective so here I give you the simplest solution. I 'm not sure it's what you are looking for.

If you just want a rigid body to keep a fixed angle you can freeze the rotation axes. It's a common practice for example to keep a character collision capsule up right.

alt text


freezerotation.png (10.8 kB)
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 Bunny83 · Feb 02, 2017 at 05:14 PM

Uhm, what do you mean by "balance"? An object can't stay at an arbitrary angle because it would not be balanced. So if you want to actively apply forces (or torque) to it to keep it's current orientation that have nothing to do with balance but would require a control system and you have to permantently applying a force / torque to keep it in it's position.

Such control systems can get very complex and have their limits (in regard of response time and error value). For things like that you usually use a PID controller. There are a few reference implementations of PID controllers in Unity

ps: just setting the center of mass is pointless when you only have a single collision point (or line in 3d) as it will never be stable in this position, even when the center of mass is exactly above the collision point.

Comment
Add comment · Show 1 · 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 Glurth · Feb 02, 2017 at 05:35 PM 0
Share

Agree. I would suggest a spring joint connected between the top/center of the rectangle, to a fixed point directly above the collision point. By adjusting the force of the spring, you will be able to adjust angle theta. It may bounce a bit a first depending on initial conditions, but should settle down to equilibrium.

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Balancing in a bike game 0 Answers

Side scroller, Scripting Bike Controls using hinge joints 0 Answers

Increasing force script, physics and a special 2 wheel Bike setting 0 Answers

Hey everyone. I need some help please. Does any of you know a Bike controller/physics tutorial? ,does anyone know any tutorials on bike movement and Physics? 2 Answers

Problem with Wheel Colliders: Jitter and unstable! 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