- Home /
Add torque is not behaving same in opposite Y direction. Need help!
Ok so I am comfortable with Unity but this is something weird for me.
What I am doing is 1. Adding force in forward direction 2. Then adding torque using AddTorque. But depending on where you click on the screen, I either do
AddTorque(transform.up*30) or AddTorque(-transform.up*30)
But the weird issue here is the negative torque is not producing the same rotation as the positive one. It just caps at a Y angular velocity of -0.09 where as the positive one keeps going higher uptil +1.5.
UPDATE: Found that gravity is causing this. If I disable use gravity then the torque behaves same either side. But how does gravity influence this?
please find the test project here. You can find it out for yourself - Open in Unity 2019.2.17 or higher https://drive.google.com/open?id=1fRCqD5wYIQmFUSx_b8pHFb_tczeOAEv0
Anyone can help me out what the issue maybe here? Am I doing something wrong?
Hey, No it is not changing the situation. Lets say you want to rotate object in Y axis to the left side(consider a boat on static collider which I want to turn, not actual water physics just on a plane) So how would you do that?
Did you ever figure it out? Also, why are you using add torque to change the rotation of an object on a plane?
Answer by tecses1 · Mar 05, 2020 at 06:37 AM
Sounds like a curious problem. I can't provide any particular solution because this is out of my scope... but if you can't figure it out I'll try playing with it. I do have some suggestions to check however, if you haven't tried them already and/or don't know where to go.
Perhaps adding torque locally with AddRealtiveTorque would make a difference. If gravity is a modifier, maybe it's the center of mass, or if it's spinning against gravity it may have an intrinsic velocity. You could try using force modes, like ForceMode.VelocityChange or ForceMode.Acceleration which ignores mass.
AddTorque(transform.up*30, ForceMode.VelocityChange);
Another option would be to re-write and mess with Rigidbody.AddForceAtPosition, which would create the negative or positive torque depending on what position/point you pick. Let me know if these suggestions get you absolutely anywhere.
Edit: Also, keep in mind rigidbody DOES have angularDrag, and maxAngularVelocity constraints.
Thanks for the help. But yes Velocity change works but its not the intended behaviour since I need it to slowly turn rather than suddenly change the angular velocity. I know i can tween the torque to change the angular velocity slowly but it seems to be a workaround.
Okay. Well if ignoring mass worked, then use Force$$anonymous$$ode.Acceleration ins$$anonymous$$d. It too ignores mass and applies force gradually.
Yep I have tried that but its the same with acceleration. Weird I know!
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Returning a rigidbody back to its original x and z rotations through physics forces. 2 Answers
How to remove all force from an object. 2 Answers
AddRelativeTorque not rotating 1 Answer
How to rotate a GameObject with another GameObject while simulating gravity? 2 Answers