Closed JayNakum closed 6 months ago
Having exactly the same stuff on my machine
Hello. Sorry for my late answer.
The issue in your code is probably because when creating the box body and collider, you are using the transform1
twice. Once for the position of your body in the createRigidBody()
method (which seems fine) but also a second time when you set the position of your collider in the addCollider()
method (that is probably wrong).
As described here in the documentation, the transform
parameter of the addCollider()
method is the transform of the collider relative to the origin of the body.
Therefore, in your case, your box body is at world-position (0, 20, 0) and your box collider is at world-position (0, 40, 0). That's why it collides with the table when the box position is around (0, -18, 0).
I hope this helps.
I am closing this issue. Feel free to reopen it if something is not clear.
Greetings! I have created a very basic test with two rigid bodies. One of them is of
BodyType::DYNAMIC
at position (0, 20, 0) and another one isBodyType::STATIC
at position (0, 0, 0). Both of the bodies has box collider of halfextents (0.5, 0.5, 0.5) and (5.0, 1.0, 5.0) respectively.Since the body at (0, 20, 0) is falling through gravity, it should ideally collide before it's position reaches (0, 0, 0) because it has a 1x1x1 collider box. But this is the output I am getting where the entity kept falling till (0, -18.68, 0), way below the expected position, after which the collision was detected.
Output
My code