You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 is BodyType::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.
The text was updated successfully, but these errors were encountered:
JayNakum
changed the title
Why is the collision not happening how I think it should happen?
Why is the collision not happening how I think it should?
Apr 19, 2024
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).
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
The text was updated successfully, but these errors were encountered: