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

Bug? ApplyForceAtLocalPoint

Mar 31, 2009 at 5:59 PM
I found this while experimenting and I noticed the torque applied to an object using Body.ApplyForceAtLocalPoint did not factor in mass.  I got the same amount of torque using a mass of 1 as I did for 100.  Changing the line:

//add to _torque
_torque += torque;


//add to _torque
_torque += (torque / mass);

appears to fix this.  Just something you might want to look at.  It's interesting that the force doesn't seem to require mass to be factored in but I haven't looked at the rest of the code that closely.

public void ApplyForceAtLocalPoint(Vector2 amount, Vector2 point)
            //calculate _torque (2D cross product point X force)
            GetWorldPosition(ref point, out _diff);
            Vector2.Subtract(ref _diff, ref position, out _diff);

            float torque = _diff.X * amount.Y - _diff.Y * amount.X;
            //add to _torque
            _torque += torque;  //<-------------should be _torque += (torque / mass);

            // add linear force
            force.X += amount.X;
            force.Y += amount.Y;