- Code: Select all
if(Gdx.graphics.getDeltaTime() < .015)
world.step(Gdx.graphics.getDeltaTime(), 3, 3);
else if(Gdx.graphics.getDeltaTime() < .065)
world.step(Gdx.graphics.getDeltaTime()/2, 3, 3);
world.step(Gdx.graphics.getDeltaTime()/3, 3, 3);
Okay im not really sure where this should go so im posting it here.
I have a segment of code where a projectile is created with an impulse based on user input.
- Code: Select all
private void createProjectiles(ProjectileID id)
PolygonShape pPoly = new PolygonShape();
BodyDef pDef = new BodyDef();
pDef.type = BodyType.DynamicBody;
pDef.position.x = 10 + (float)Math.abs(7*(float)Math.cos(MathUtils.degreesToRadians*cannonAngle));
pDef.position.y = 9 + (float)Math.abs(7*(float)Math.sin(MathUtils.degreesToRadians*cannonAngle));
Body pBody = world.createBody(pDef);
Vector2 theImpulse = new Vector2(power*(float)Math.cos(MathUtils.degreesToRadians*cannonAngle),
projectiles.add(new Projectile(pBody, pType));
This segment of code is called by a touchUp event, if that matters.
The values that are placed in the impulse are always the correct values. That being said for some reason the velocity of the body in question is dependent on FPS. I thought that perhaps it was the impulse using the getDeltaTime as its duration, so instead i used a force in place of an impulse and it is still dependant on FPS. After that frustration i simply set the velocity equal to theImpulse. Still no good. Im obviously missing something very easy. any help would be abliged.
When the FPS are 60+ it works fine, however when i port it to my phone and the FPS bounce from 20-35 i get different speeds of the projectile based on the FPS (or getDeltaTime not sure) at that instant.
I also tried to change the values of the pDef instead and i cannot get it to operate correctly. Any help would be greatly appreciated.