I’m trying to simulate a classic pendulum science experiment on unity.
So just for a prototype, I attach a hinge joint on my weight(pendulum) with a connected body of a gameObject(anchor).
Everything works fine until I try to move the weight programmatically.
It seems like whenever I tried to move the mass, the hinge joint anchor won’t stay in place. I’m not sure if this is a physics problem or scripting problem.
I checked the inspector and the anchor axis doesn’t seemed to change.
Below is the GIF of my problem, and a script of how I move my weight programmatically.
The red circle shows the anchor not staying in place when i click or move the weight, and the grey circle is just a guide of where the anchor should be.
First of, thanks. I tried changing it to move the RB and it works. The anchor now stays in place.
But, I have another problem that came up. The pendulum works fine, but when it’s rotation or the swinging angle reach somewhere about 1 to 2 degree, it began to swing all over the place like below.
I not sure how to fix this as there is no script that changes or update the weight’s position and rotation. I just use unity’s hinge joint and gravity to do its work.
This problem is consistent to happen when the swinging angle is less than 2 degree and when it is about to stop.