I kinda got this problem since I started using ChipMunk and it's propably something very simple that I just don't see.
I have a game running in Cocos2D with Javascript bindings (Javascript that calls c++ API)
It's currently using chipmunk as physics engine. The Problem I'm having is that I start making my floor to prevent falling of the screen:
Code: Select all
function() {
var body, shape, size;
size = cc.Director.getInstance().getWinSize();
body = new cp.Body(1000, Infinity);
body.setPos(cc.p(size.width / 2, g_groundHight / 2));
shape = new cp.BoxShape(body, size.width, g_groundHight);
shape.setSensor(false);
shape.setFriction(0);
shape.setElasticity(0);
shape.setCollisionType(kTagWall);
this.space.addShape(shape);
this.wallBody = body;
return null;
}
This all works and my floor box is created, the problem I'm having is that once my player gets on the ground it starts bouncing up in the air really high at random times.
It's quite annoying and I've tried a lot, but haven't found any real answer to this problem.
I hope you guys might have an idea of what's going on here, any more code needed will be given, and thanks in advance for helping!
The behaviour is not like bouncing by the way, because when my player falls down again and hits the floor, there's no new bounce. It just happens to shoot in the air randomly.
Also, my timestep is fixed to 1/60 so I dont think it's because of framedrops or anything else.