Hi, I'm trying to use joints in my class so I tried to make a function but it seems not to work…
It should create a distance joint between the two bodies from another class Ball stored in a std::vector.
This part of code makes my game freezing so I wonder what's the problem in it.
Do you have any idea ?
Thanks.
Code:
void Level::link(int b1, int b2)
{
b2Body* body1 = m_Ball[b1]->getBody();
b2Body* body2 = m_Ball[b2]->getBody();
b2DistanceJointDef jointDef;
jointDef.Initialize(body1, body2, body1->GetPosition(), body2->GetPosition());
jointDef.collideConnected = true;
jointDef.frequencyHz = 4.0f;
jointDef.dampingRatio = 0.5f;
m_Joint.push_back(m_world->CreateJoint(&jointDef));
}
{
b2Body* body1 = m_Ball[b1]->getBody();
b2Body* body2 = m_Ball[b2]->getBody();
b2DistanceJointDef jointDef;
jointDef.Initialize(body1, body2, body1->GetPosition(), body2->GetPosition());
jointDef.collideConnected = true;
jointDef.frequencyHz = 4.0f;
jointDef.dampingRatio = 0.5f;
m_Joint.push_back(m_world->CreateJoint(&jointDef));
}
It should create a distance joint between the two bodies from another class Ball stored in a std::vector.
This part of code makes my game freezing so I wonder what's the problem in it.
Do you have any idea ?
Thanks.