Infinite pendulum with hinge joint 2d
I am creating a platform game and I want to add a pendulum obstacle. I have a wrecking ball object with a Hinge Joint 2D swinging back and forth. The wrecking ball is released at a 90 degree angle to start the pendulum. My problem is that the angular velocity of the wrecking ball slows down over time and stops eventually. I want the wrecking ball to swing in the same way for an infinite amount of time. How could I go about acheiving this?
Any help is much appreciated
Answer by sandin · Oct 21, 2016 at 08:56 AM
Same problem here, it slows down. No answer found in Internet :(
Hi again.
As the engine can't do it by itself (it always lose energy over time no matter what), I just implemented a workaround for the infinite pendulum movement that works perfectly here: just give some impulse to the pendulum in each movement, and it will move infinitely, in equilibrium. The more you "push", the higher the angle, that's it:
void Update () {
if (bajando && transform.position.y > y)
{
bajando = false;
rb.AddForce(rb.velocity * thrust);
}
if (!bajando && transform.position.y < y)
{
bajando = true;
}
y = transform.position.y;
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612075511im_/https://answers.unity.com/themes/thub/images/avi.jpg)