Yea, changed to that method now. First I did it so the server would get less load but then I tought about the sending int vs. float to the client.
But I still got a problem.. I don't want to replicate static objects.
So on the server I got this
b2BodyDef bodydef;
bodydef.type = b2_dynamicBody;
//bodydef.type = b2_staticBody;
bodydef.position.Set(0,0);
b2Body* body = world.CreateBody(&bodydef);
b2PolygonShape box;
box.SetAsBox(184.0f * METERS_PER_PIXEL, 230.0f * METERS_PER_PIXEL);
b2FixtureDef fixdef;
fixdef.shape = &box;
fixdef.density = 1.0f;
fixdef.friction = 0.3f;
body->CreateFixture(&fixdef);
// this will not be sent to the client
b2BodyDef gdef;
gdef.type = b2_staticBody;
gdef.position.Set(0,(230.f * 2.f) * METERS_PER_PIXEL);
b2Body* ground = world.CreateBody(&gdef);
b2PolygonShape gbox;
gbox.SetAsBox(3.f, 0.1f);
ground->CreateFixture(&gbox, 0.0f);
and this is how I set the position on the client for the static body
// static body
sf::RectangleShape rs;
rs.SetSize(sf::Vector2f(3.f*64.f, 1.f * 64.f));
rs.SetOrigin((3.f * 64.f) / 2.f, (1.f * 64.f) / 2.f);
rs.SetPosition(0.f, 230.f * 2.f);
rs.SetFillColor(sf::Color::Blue);
// dynamic body - gets updated behind the scenes
sf::Texture img;
img.LoadFromFile("C:\\MyGameEngine\\Assets\\test.jpg");
sf::Sprite spr(img);
spr.SetOrigin(92, 115);
But when they collide serverside and the client paints them there is still something like 30-40 pixels between them.. Soo there have to be something wrong in my converting of the positions. Anyone care to help me out here?
edit:
forgot to mention that I'm going with 64pixels = 1meter in box2d
Edit: Found out why.. Find my typo and see how retarded I am. Then range my retardness 1 - 10.