Consistant/deterministic physics - What am I doing wrong?

  ... the Physics Box2D Extension for AndEngine.

Consistant/deterministic physics - What am I doing wrong?

Postby OzLark » Sun Feb 26, 2012 5:07 am

I just can't seem to get my physics to work as I expect it should.

So, originally I was using the basic PhysicsWorld class but had issues with my objects 'landing' in place and bouncing around without having any impacts occurring - this was not good. So under advice given here I changed to using a FixedStepPhysicalWorld - this seems to fix these issues.

My physics world is defined as such:

Syntax: [ Download ] [ Hide ]
Using javascript Syntax Highlighting
  1. this.mPhysicsWorld = new FixedStepPhysicsWorld(30, 1, new Vector2(0, SensorManager.GRAVITY_EARTH), false, 8, 4);
  2. this.mPhysicsWorld.setContinuousPhysics(false);
  3. this.mPhysicsWorld.setAutoClearForces(true);
  4.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


So I though this was done and dusted, but then yesterday I tried my game on a freinds more modern phone (I think it was a HTC Sensation S, I've been developing on a HTC Desire) and the physics behave differently. I have a sceen which has some balloons stuck in a area obstructed by some blocks. In my update handler I make my balloons float by doing:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. final Body b = mPhysicsWorld.getPhysicsConnectorManager().findBodyByShape(s);
  2. tmpVector2.x = 0;
  3. tmpVector2.y = ((-SensorManager.GRAVITY_EARTH - 0.3f) * b.getMassData().mass);
  4. b.applyForce(tmpVector2, b.getWorldCenter());
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


This works great on the desire, but on the Sensation S the balloons have enough force to lift the block that is obstructing them - such the block lifts and the balloons escape and fly away.

Why is this different on the two different devices? How can I make the physics bahave the same regardless of the devices performance capaility?

Any ideas?
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Re: Consistant/deterministic physics - What am I doing wrong

Postby OzLark » Tue Feb 28, 2012 2:11 pm

Bump..

No one has any ideas?

I'm sure some out there are using the physics engine successfully - what's the trick?
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Re: Consistant/deterministic physics - What am I doing wrong

Postby RealMayo » Tue Feb 28, 2012 7:04 pm

I've not yet tried my game on any other devices. The device I'm testing on is a "more modern phone", the HTC Evo

The fixedStepPhysics I use is this...
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. PhysicsWorld mPhysicsWorld = new FixedStepPhysicsWorld(30, new Vector2(0f, 9.8f), false, 8, 1);
  2.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

And I do NOT specify these at all...
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. this.mPhysicsWorld.setContinuousPhysics(false);
  2. this.mPhysicsWorld.setAutoClearForces(true);
  3.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


I'm actually curious what may happen when I test my game on an older lower powered phone. Till then, sorry I can't be of more help.
User avatar
RealMayo
 
Posts: 1682
Joined: Sat Sep 03, 2011 9:25 pm
Location: Chicago, IL


Return to Physics Box2D

Who is online

Users browsing this forum: No registered users and 9 guests