I want to create an infinite pendulum by just using physics. I created a rigidbody and a hinge joing on the mesh. I set the Drag and Angular Drag to 0 and when I start the simulation with the pendulum 90 degrees rotated, it works but over some time it slows down until it stops due to gravity.
I tried motors and spring joints but no luck, motors only add force through one angle and springs slow down too.
A pendulum shouldn’t stop due to gravity. The pedulum stops due to the nature of the physics calculations in the engine. Look up numerical integration for details.
Therefore, a pendulum using just physics is unlikely to ever work. You’ll need to create a script.
As I recall, there’s a metronome example project on the Apple dev site somewhere - if that behavior is what you want (but upside-down, of course), you could examine the code and convert it to a Unity script.
Edit: Sorry, I just remembered that metronome example is an iPhone project - not sure if you have access to the Apple iPhone dev site.
In essence physics will slowly steal energy from a system through a combination of damping and small errors. The workaround for such cases is to store a system’s starting energy and then reset the system’s energy to the starting value at convenient intervals. For a pendulum you’ve got kinetic energy and potential energy – simply total these up when the pendulum is released and then restore them (presumably by changing the system’s velocity) occasionally.