[Solved] can't make body move faster

Topics: User Forum
Aug 25, 2012 at 2:29 PM
Edited Aug 26, 2012 at 9:42 AM

 

        Dim body As New Body(world)
        With body 
            .BodyType = BodyType.Dynamic
            .Position = location
            .ApplyLinearImpulse(New Vector2(30, 0)) 
        End With
        Console.WriteLine(body.Position.ToString)
        world.Step(1000)
        Console.WriteLine(body.Position.ToString)

 

Here's my code. (in VB.net)

The body only moves by 2 units max whatever the value of the impulse or step is.

How do I make it move more?

 

I know I'm suppose to use a display/sim scale but if my scale is 100 then I'll only be able to move a body 200 pixels?

Aug 26, 2012 at 11:19 AM

Well, Farseer probably uses some form of numerical integration and I doubt that it can handle such a huge step size. Perhaps you can try this (I haven't programmed in Basic for a very long time, so there might be some syntax errors:

 

Dim body As New Body(world)
With body 
   .BodyType = BodyType.Dynamic
   .Position = location
   .ApplyLinearImpulse(New Vector2(30, 0)) 
End With
Console.WriteLine(body.Position.ToString)
Dim totalTime as Single = 1000F

Dim stepSize as Single = 0.02F
Dim totalSteps as Integer = CInt(totalTime / stepSize)

For i = 0 to totalSteps
   world.Step(stepSize)
Next
Console.WriteLine(body.Position.ToString)

Aug 26, 2012 at 11:47 AM

I need it to simulate a hit-scan bullet with "infinite" speed.

Is there another way to accomplish the above without using multiple world steps?

Aug 26, 2012 at 12:39 PM

Two things might help, maybe

1. Farseer has a max speed setting that will restrict the speed bodies can get too. the comment says that this speed is quick and should not need to be passed. if you need to go faster, then probably worth changing the game to physics dimensions scale, or just manually raise this upper speed limit :)

2. It sounds like what you need to use for an infinite speeding bullet is a ray cast. 

Aug 26, 2012 at 1:18 PM
Edited Aug 26, 2012 at 1:22 PM

Raycast seems like what I need.

Thanks for your help.