Box2D Forums

It is currently Sat May 18, 2013 10:41 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Jul 25, 2012 10:03 am 
Offline

Joined: Mon Jul 23, 2012 4:14 pm
Posts: 2
Hi,

It's my firt time with JBox2d (use to develop a platform game) and something weird happens with my "main character" (who's actually only a rectangle dynamic body):

Once he touches the platform under him, he collides and stays on it. Great, but the gravity doesn't reset upon contact and my body, who cans actually jump, is unable to jump after few seconds, due to a gravity that tackle him on the ground and continually raises on my character.

My question is: did I miss something about: me who must reset the Y-axis force on my object at each contact, or my world is misconfigured or anything else? I tried to set world.ClearForces() and set his autoClearForces to "true", but nothing changes that behavior.

Thanks anyone.


Top
 Profile  
 
PostPosted: Fri Aug 03, 2012 6:26 am 
Offline

Joined: Tue Jul 31, 2012 7:46 am
Posts: 11
Firstly, what code have you got so far? And secondly, gravity is supposed to be a constant vector in the Box2D world, so it is not supposed to reset upon contact or grow.


Top
 Profile  
 
PostPosted: Mon Aug 06, 2012 4:41 pm 
Offline

Joined: Mon Jul 23, 2012 4:14 pm
Posts: 2
There's my singleton to create my physic world at the beginning of the game. The Conversion class converts units from my graphical world to my physical world to stay to a good scale:

/*
* Singleton for physic world.
*/
public static World getWorld(){

if(myWorld == null){
accumulator = 0.0f;
myWorld = new World(new Vector2(0, Conversion.worldToBox(-20)), true);

//Only add to test if it could changes the behavior I had.
PhysicManager.getWorld().setAutoClearForces(true);

//Set callbacks.
myWorld.setContactListener(new GroundListener());

//Use to see the edges of bodies.
debugger = new Box2DDebugRenderer(true, false, false, true);
camera = new OrthographicCamera(15, 15);
camera.position.set(0, 0, 0);
}

return myWorld;
}

My problem isn't that the gravity grows or must reset, but that my "character" is constantly pulled down and, once upon the platform, won't be able to jump due to an excessive force applied on him. I try to discribe it the best way possible, but it's hard to clearly express.

I want to know if I must do something to reset the force applied on my character while he stands on an object or then that the engine is misconfigured (by me) and should affect the force applied on any object upon contact.

Exemple: (Gravity) Y-axis force on my char: 0, -5, -10, -15, (fell on the platform), -20, -25, -30, etc. My character can jump with a force of 30, but the force applied is higher.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group