So I have a player (Box2D box) that can be moved horizontally with 'A' and 'D' using:
SetLinearVelocity(b2Vec2(speed, object.getB2Object()->GetLinearVelocity().y));
But when I move the box the player doesn't slide but roles on the corners like so:
I figured out that decreasing the friction of the box and the ground prevents this to some extent but still happens fairly regulary and also makes the player slide further when stopping. I have tried the function SetFixedRotation(true) but this seems to make the player stop moving all together, presumably at the points where it was going to rotate. I also tried SetAngularVelocity(0) but this still makes the box rotate, although very slowly. Is there another way to prevent the player from rotating when moving on a surface? Thanks
[Edit]
After doing what pingul suggested by setting the friction to zero the box hardly rotated. It looked like it was tripping on something every so often so, instead of 10 individual tiles for the floor I removed them and created a wide tile and the problem stopped! Therefore I think the box was tripping on the next tile along. My next problem then is why is this happening as I know the tiles all have the same height, width and position as shown here:
//the number of tiles
const unsigned int MAX_TILES = 10;
for(int i = 0; i < MAX_TILES; i++){
//position ,size ,density ,linear_damping ,friction ,isdynamic,b2World
tiles.push_back(new GameObject(vec3(6+i-(MAX_TILES/2), -10, 1), vec3(1, 1, 0), 1.0f ,1.0f ,0.5f ,false ,world_b2));
tiles[tiles.size()-1]->Init(); //Some OpenGL stuff for rendering
tiles[tiles.size()-1]->getMesh()->setTexture(test_sheet.getTexture(2,0)); //gets a texture from sprite sheet class
}
[Edit 2]
Math Library Using: GLM
Overlapping the tiles in the horizontal direction does nothing but I think it have something to do with this but in the vertical axis. When the player goes on to another tile, rotating or not, the y value changes slightly. This can be either up or down and only changing by +-0.003~. When jumping though it will go back to the very first value when the game starts on any of the floor tiles.