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:
87181-1.png
So i want to make theta equal to 0, like this:
87182-2.png

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 :slight_smile:

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.

87219-freezerotation.png

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.