Objects going though each other
sacha-pierot opened this issue · comments
Hello,
First of all, nice library! I just have one problem, colliders go through each other :D
What I do is :
- Update physics
- Update my objects position with the newly calculated positions
- Render
The collision tests work, testCollision() and testOverlaps() both return right values when the rendered colliders actually collide, but no bounce.
Here is my code, Transform class is my own code, but works just as any Transform class :
const float constantTimeStep = 0.02f;
while (m_OldTime < time)
{
m_PhysicsWorld->update(constantTimeStep);
m_OldTime += constantTimeStep;
}
m_OldTime = time;
for (int i = 0; i < bodies.size(); i++)
{
auto* body = bodies[i];
auto* transform = body->object()->transform();
const rp::Transform& rp3dTransform = body->b->getTransform();
rp::Vector3 rpNewPos = rp3dTransform.getPosition();
rp::Quaternion rpNewRot = rp3dTransform.getOrientation();
transform->setPosition(glm::vec3(rpNewPos.x, rpNewPos.y, rpNewPos.z));
transform->setRotation(glm::quat(rpNewRot.w, rpNewRot.x, rpNewRot.y, rpNewRot.z));
}
Never mind, i needed to create a Rigidbody instead of a CollisionBody .
RigidBody and CollisionBody don't collide, i suppose it's for triggers only :)