- Home /
Object always torques towards upright
Hey guys, quick question. I'm trying to get a buoyancy effect going for a boat, and what I need is a way to have the boat resist being tilted in the x and z axes. Best case scenario, it would torque hardest around an axis when rotated 180 degrees from the 0 of that axis.
So, what I need is a rigidbody.AddTorque statement that affects the x and z axes, dependent on the signed difference in angle from 0. Any ideas?
Thanks a lot, you guys are great!
I'm convinced there's some kind of magic torque application, along the lines of rigidbody.AddTorque( transform.forward * c ), c being a constant. This doesn't work, but I think there's some magic combination that will do the trick.
I want to believe...!
Got something that works pretty well, actually. Pieced this together from other UnityAnswers.
rotationDelta = Quaternion.FromToRotation(transform.up, Vector3.up);
rigidbody.AddTorque( rotationDelta.x buoyantTorque, rotationDelta.y buoyantTorque, rotationDelta.z * buoyantTorque );
Answer by Mold · Jul 25, 2012 at 11:20 AM
I guess the boat has a rigidbody? lock Z rotation?
That's no fun... we need wobbly boat physics! : P