- Home /
Prevent rigidbody with hinge joint from slowing down
I created this model: The log swings around its support. This support is the parent object of the log and has no Rigidbody and just consists of a mesh. The log has these components which are used for the swinging: You may see that it doesn't use gravity, so I simulated gravity with this line of code:
rigidbody.AddForce(direction * 9.81f);
"direction" is just the vector which points towards the stone path, so basically down
So here is my problem: The log is slowing down. It doesn't just swing there forever, instead its speed gets less and less, like if it's affected by friction. Its rigidbody already has angular drag set to zero, so I honestly don't know what causes this. If you have any idea, please let me know. Thanks!
Answer by metalted · Jun 18, 2019 at 08:19 PM
Well its doing exactly what you tell it to do right? Aside from the changed gravity direction its the same as any other swinging log. The force will pull it towards the earth and at some point it will stay there. Just like a regular pendulum on earth. If you want it to keep swinging you should add some force to it, just like a swing set. You could of course also fake it. Just because a log swings with a "hinge joint" in the real world doesn't mean it has to do it in your game. You could also just rotate the log around its pivot point using a Mathf.Sin or a pingpong function. It will do exactly the same as you want it to do with the rigidbody, with less of the hassle of joints and rigidbodies.
Actually that's no bad idea to just fake it. I am gonna try with this one, thank you!
Yeah rigidbodies and joints are really tricky. They can break, they can shift apart, fixed joint are not really fixed and can become loose under the weight. In most cases when I wanted to achieve an effect in my scenes, I would be stuck in a way how it works in the real world and try to copy that. But most of the times, I would resort to a simpler solution of just translation and rotation and I would get the same effect. But it always hard to deter$$anonymous$$e if you really need rigidbodies or not.
Exactly, I also had some hard times with joints in some of my other games. Sometimes you're better off without physics :D
Your answer
Follow this Question
Related Questions
A position locked hinge joint with drag and no gravity? 1 Answer
How to have a sphere roll/be affected by friction 0 Answers
Physic Torque Hinge joint problem 0 Answers
Faux Gravity help 0 Answers
How to add gravity without a rigidbody 2 Answers