Turning speed limits

Here's the place to get help and discuss features. The focus is on the C++ version, but generic questions are welcome.
warbarons
Posts: 3
Joined: Fri Oct 13, 2017 3:46 am

Turning speed limits

Postby warbarons » Mon Oct 16, 2017 4:26 am

Hi.

New to box2d here but got everything up and running finally. I'm making a top down car game. I'm going for simple physics for now, just applying impulses on a rectangular box with a car sprite. My problem is that I can't make it rotate fast enough. It's as if there is a limit that I hit when rotation is still slow.

Code: Select all

this.player.applyAngularImpulse(+0.6, true);


Code: Select all

this.player.setAngularVelocity(4);


This are the lines I tried with a sorts of numbers to make it turn faster.

Here is setting up my body:

Code: Select all

this.player = this.world.createBody({
            type : 'dynamic',
            angularDamping : 8,
            linearDamping : 0.8,
            position : this.pl.Vec2(1100 / Constants.SIZE_RATIO, 600 / Constants.SIZE_RATIO),
            angle : 0, //90 * Math.PI / 180,
            allowSleep : false
        });


Here is adding my fixture:

Code: Select all

this.player.createFixture(this.pl.Box(37 / Constants.SIZE_RATIO, 61 / Constants.SIZE_RATIO), {
            density : 200,
            friction: 0.4,
            restitution: 0.1
        });

        this.player.setMassData({
            mass : 3,
            center : this.pl.Vec2(),
            I : 1
        });


I've changed SIZE_RATIO between 10 och 50. The thing is when I look at tutorial examples they use similar numbers as I do. I've played around with a few numbers on angularDampening and mass but still rotates too slow.

Here is my world:

Code: Select all

        this.world = this.pl.World();
        this.world.setGravity(this.pl.Vec2(0.0, 0.0));
       


Any ideas what I'm doing wrong here? Why does my object refuse to spin faster?

Louis Langholtz
Posts: 21
Joined: Tue Dec 20, 2016 10:53 am

Re: Turning speed limits

Postby Louis Langholtz » Wed Oct 25, 2017 7:38 pm

There is a rotational speed limit of b2_maxRotation (which is set to 0.5 * b2_pi). That's a limit per step however which at 60 steps / second of simulated time, is over 90 radians per second. That will be the max rotational speed that a body can be accelerated to or set to short of upping the max rotation value or decreasing the time elapsed that's being simulated per step. Are you running into this limit perhaps?

warbarons
Posts: 3
Joined: Fri Oct 13, 2017 3:46 am

Re: Turning speed limits

Postby warbarons » Thu Oct 26, 2017 6:42 am

Honestly I'm not sure what the problem was but I got it working eventually and continued on my project. Could have been something with size but then again I think I tested everything again and again so I'm not sure what it was.

Cutright
Posts: 1
Joined: Tue Nov 14, 2017 4:37 am

Re: Turning speed limits

Postby Cutright » Wed Nov 22, 2017 7:36 am

warbarons wrote:Honestly I'm not sure what the problem was but I got it working eventually and continued on my project. Could have been something with size but then again I think I tested everything again and again so I'm not sure what it was.


That's odd, but at least you got it working. I wish you could pinpoint what was the issue, just for future reference.


Return to “General Discussion”



Who is online

Users browsing this forum: No registered users and 2 guests