Yup i know there isI've created a "Assertion failed: (IsLocked() == false" problem caused by world->step(...) in update function. And I have to had my bullet body and stored after initialization.a reference to it in herobody
:
bDef.type = b2_dynamicBody;
bDef.position.Set(herobody->GetPosition().x, herobody->GetPosition().y);
b = world->CreateBody(&bDef);
b2FixtureDef fixturebDef;
b2CircleShape circlebShape;
circlebShape.m_radius = 0.05;
fixturebDef.shape = &circlebShape;
b->CreateFixture(&fixturebDef);
but i dont know howI'm trying to change the current position of the bullet connected with herobody. I tried to use setTransform b2bodySetTransform
but it make the same asseration problemI get an error :(Assertion failed: (IsLocked() == false)
during world->step
in my update
method.
/// This doesn't work. Causes the above assertion.
/*
b->SetTransform(
b2Vec2(
herobody->GetPosition().x,
herobody->GetPosition().y
),
0
);
*/
// DOESThis NOTworks, WORK;/but doesn't set position directly.
b->ApplyLinearImpulse(b2Vec2(5, 0), b->GetWorldCenter(),true);
Can anyone know how to fix it or how to write correct function forHow do I do this correctly?