This project has moved and is read-only. For the latest updates, please go here.

Revolute Joint distance problem.

Topics: Developer Forum
Apr 4, 2011 at 4:17 AM

Quick question about revolute joints.

I have a revolute joint to which rotates one body around another using the motor based on the position of your cursor. The problem is the further away the satellite body is the more the joint seems to wobble. So if I have the satellite body close to the other body it rotates perfectly based on the cursor position, when I move it further away it spasms.

Is there a way to stop that? This is my rotation code:

                float rotation = (float)Math.Atan2(position.Y - _body.Position.Y, position.X - _body.Position.X);

                float angleError = _joint.JointAngle + rotation;

                if (angleError <= -3.14159265f)
                    angleError += 6.28318531f;
                if (angleError >= 3.14159265f)
                    angleError -= 6.28318531f;

                float gain = 10.0f;

                _joint.MotorSpeed = (-gain * angleError);

Apr 5, 2011 at 3:31 AM

Is there a different type of joint I should be using, or perhaps a combination of two joints?

Apr 6, 2011 at 1:45 AM

Can't figure this out. ReferenceAngle also seems to randomly get set to a small number which affects things.

Apr 7, 2011 at 1:07 PM

Nobody have any suggestions? I would have thought more people would have encountered this problem.