Scale mesh collision on runtime

https://playcanvas.com/editor/scene/737372

I am scaling an entity and i need the mesh collision to scale with it.
This is a simplified scene where i scale a cube with setLocalScale but the collision component remains the same size.

Is there a way for the collision component to scale?

Thanks in advance.

You can’t scale at runtime unfortunately. Ammo.js doesn’t allow it (looking at the API). You can destroy the mesh collision and recreate (as seen here: https://github.com/playcanvas/engine/blob/1f0908774780fa21442a7ada1a12ef99437a87f9/src/framework/components/collision/component.js#L193) but that isn’t something you want to do every frame. The occasional resizing will be ‘fine’ but if you want to scale something something overtime, I’m afraid that is not possible.

1 Like

Like always. thank you very much.