Problems with Box2D on Andriod

Discuss issues specific the Java port of Box2D
Posts: 2
Joined: Fri Sep 23, 2016 10:16 am

Problems with Box2D on Andriod

Postby Outstream » Fri Sep 23, 2016 10:49 am

I have two problems with my OpenGL ES Android application running the java port of Box2D

My first problem is that the processing is very, very slow. I am running step with these parameters:

Code: Select all

float timeStep = 1.0f / 60.0f;
int velocityIterations = 10;
int positionIterations = 10;

With these settings, the game appears to run in slow-motion. I can make the game process faster by reducing the step to 30FPS but this limits the max velocity (something I don't want). The processing usually handled at about 16-23ms, I know this shouldn't isn't correct but based on my research this isn't the cause of my problem.

My second problem is that Box2D is not changing body rotations on collisions. If I manually rotate the body and attempt to collide on an angle, the hitboxes are correct.
This image is a result of the rotated box being dropped and falling due to gravity
For both bodies: mass=1, density=10, and friction = 1.3

Posts: 2
Joined: Fri Sep 23, 2016 10:16 am

Re: Problems with Box2D on Andriod

Postby Outstream » Sun Sep 25, 2016 12:25 pm

Sorry for a stupid post, I don't have much knowledge on Box2D. The reason I couldn't find the answer is probably because it's a simple problem but due to drawing in OpenGL it made the first problem a bit more complicated.

Anyways, in case someone end up here with the same problems:
The first problem was due to improper scaling.
The second problem was because I was setting the mass of the bodies after I had set the fixture.

Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest