Cylinder goes through box, using Ammo.js

Playground demo

We have a cylinder (like an ice hockey puck) which can bounce and slide against some obstacles. They aren’t always boxes so we’re using a MeshImposter instead of a BoxImpostor, but we get the same behaviour with a BoxImposter.

The demo is set up to launch the puck towards the wall at varying speeds every second. Sometimes the puck will go through the wall, usually it bounces off correctly.

I don’t think the puck’s velocity is very high, I’d certainly expect the puck to bounce correctly every time at the velocities being used here.

Can anyone help?

Thanks very much

1 Like

adding our ammo chief @Cedric who I am sure will have a good explanation :slight_smile:

1 Like

Hi @bamsarker and Welcome to the forum!

With high velocities, collision detection can be missed. Usually, when it happens you have to increase the steps so the detection is more reliable.

I’ve modified your PR :
first, I set the ammojsplugin to support delta for world steps
then, I removed the max steps and I’ve added a call to setSubTimeStep as explained here : Use Advanced Physics Features - Babylon.js Documentation
Basically, if you have 16.6 ms between 2 frames and have a subTimeStep of 1ms, it will compute 16 steps. This will be more accurate.


Thanks @sebavan and @Cedric for the explanation.

This was helpful, unfortunately we’ve tried it and we found on mobile devices it slows everything right down. It could well be other stuff we’re doing.

I’ll try to get a PG example to demonstrate this next issue, but I’ve just set the sub time step to 4, it seemed to improve things regarding impostors going through other impostors. In a level with ~5 meshes, all boxes, it’s running pretty smooth: ~55 fps. Then I get to a level with meshes which aren’t boxes but are still fairly basic, and it plummets to <1 fps.

Like I said, I’ll try to get a PG example showing this behaviour.

Thanks very much for your help

1 Like