Home > Back-end >  Is there a max speed in Forge2D
Is there a max speed in Forge2D

Time:10-11

When I try to do applyForce or applyLinearImpulse, I can only get a slow (but stable) speed regardless of how much force I add. Is there a max speed that is applied and restricting my bodies from going faster? I want to be able to have a bullet shooting effect.

I have checked some tutorial, but the velocity still seems too slow, even if I set body.linearVelocity = Vector2(5000, -5000); it moves slow.

  @override
  bool onTapDown(TapDownInfo info) {
    body.applyLinearImpulse(Vector2(5, -1) * 1000000000);
    return false;
  }

gravity is zero, and here is body data:

  @override
  Body createBody() {
    final Shape shape = CircleShape()..radius = 30;
    final bodyDef = BodyDef(
      userData: this,
        angularDamping: 0,
      position: Vector2(100, 500),
      type: BodyType.dynamic,
    );
    final fixtureDef = FixtureDef(shape)
      ..shape = shape
      ..restitution = 1
      ..density = 0.0001 
      ..friction = 0; 

    return world.createBody(bodyDef)..createFixture(fixtureDef);
  }

thank you!

CodePudding user response:

This is due to that you have set the zoom level to 1, instead of 10 which is the default. This makes the bodies hit the top speed very quickly, so instead you should just make the bodies smaller and zoom in on them. This is not only Forge2D specific, but applies to pretty much all ports of box2d and box2d itself. You can read more about it here.

  • Related