Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objects going though each other #361

Closed
ghost opened this issue Nov 27, 2023 · 1 comment
Closed

Objects going though each other #361

ghost opened this issue Nov 27, 2023 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 27, 2023

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));
}

And here is a image showing what happens :
image

@ghost
Copy link
Author

ghost commented Nov 28, 2023

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 :)

@ghost ghost closed this as completed Nov 28, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants