[Solved] ApplyForce() has less impact without ApplyTorque()

Oct 5, 2012 at 12:28 AM
Edited Oct 21, 2012 at 6:55 AM

I am unable to recreate this in the TestBed, so there should be something wrong with my code.  I'm at a total loss after stripping it so it looks like the TestBed.

 

Problem:

I have an object with some LinearDamping and Mass.

If I ApplyForce(moderate force), the results are expected. The object accelerates until it reaches the expected final velocity.

If I ApplyForce(small force), something weird happens. The object moves slow. If I apply a small amount of torque, it accelerates to the expected velocity. (No more torque is required.)

Any idea what causes this?

 

 

Here's some specs:

LinearDamping=1f, Gravity=0,0., Mass=40, Friction=0. AngularDamping unset.

 

Update(GameTime gameTime)
{
if (ScreenManager.Input.IsKeyDown(Keys.Space)) {

            
                _bdy.ApplyForce(ConvertUnits.ToSimUnits(new Vector2(50, 0))); 
                Console.WriteLine(_bdy.LinearVelocity.Length());
            } World.Update(GM.WorldTargetTime); //TestBed shows this isn't the cause
            
}

Console without torque:
0
0.0099
0.019701
0.02940399
....
.08561793
.09466175
.1036151
0
0.0099
0.19701
[cycles]

Console with torqu:
0
[steadily accellerates]
.9899947
.9899947
.9899947
.9899947

Console when max speed is 3, but decreases to 1
3
[steadily decreases]
1.0003
1.0003
Oct 5, 2012 at 7:37 PM

Have you tried playing with the values in Settings.cs. Perhaps it's the VelocityThreshold (speed is way below the default of 1f). 

Even if it doesn't help having relative speeds below the threshold (like with static bodies) will mean your collisions will be totally inelastic which is perhaps not what you want. Might be easier to upscale the world a bit in order to not have very low (or very big for that matter) values.

Oct 6, 2012 at 7:27 PM

Thanks Jerry, settings seems to be a good place to start.

Oct 21, 2012 at 6:53 AM
Edited Oct 22, 2012 at 7:53 AM

I've tried really hard to see if any of the FarseerPhysics.Settings tweaks would fix it. I am content that all of the variables are ok.

 

Is there any chance that Settings.epsilon could be the cause? It is a small number, no description, affects island solving, and a "static distance" class.

Any ideas what to lookf or?

Oct 22, 2012 at 8:14 AM
Edited Oct 22, 2012 at 8:25 AM

I think I've found something. Playing with TimeStep, force values that 'used to work' no longer work.

This is what my TimeStep looks like on Game Init



            GM.TargetElapsedTime = TargetElapsedTime.TotalMilliseconds;
            GM.TargetWorldTime = ConvertUnits.ToSimUnits(GM.TargetElapsedTime );

 

This is how it looks like in Update:

             World.Update(GM.TargetWorldTime);

 

How do I fix my World Time Step?

Coordinator
Oct 22, 2012 at 8:12 PM

Try with a fixed timestep to see if that solves anything.

Example: World.Step(1/60f); //60 FPS

Also make sure that you scale your units correctly. Have a look at the Testbed and Samples framework on how to do this.

Oct 22, 2012 at 10:05 PM
Edited Oct 22, 2012 at 10:07 PM

Thanks Genbox.

It happened to be a combination of fixing World.Step(DeltaTime), and compensating the units.

This is what it looks like for me now:

WorldTargetTime=TargetElapsedTime*.001f;

World.Step(WorldTargetTime);

All 'force' units (Damping, Velocity, Forces) are multiplied by 10