Hey @jonathan – I was playing around with matter.js and this seems like a trivial feature to add.
- how to prevent rotation when collision occurs? · Issue #39 · liabru/matter-js · GitHub
- Prevent rotation · Issue #104 · liabru/matter-js · GitHub
inertia: 'Infinity'
Apparently, capitalization matters. I tried it and my tomato enemy stopped spinning.
Update - It's not so trivial. While I was able to stop my tomato from spinning, it started again after I scaled the tomato.
Matter.Body.scale(red, 1, 1);
Even with no actual scaling going on, the tomato started spinning again.
Update #2 - OK, so when the body is scaled, it seems the physics properties are altered somehow.
It says this...
Scales the body, including updating physical properties (mass, area, axes, inertia), from a world-space point (default is body centre).
So, the trick is to just reset the Inertia after scaling the body.
Matter.Body.scale(red, 1, 1);
Matter.Body.setInertia(red, 'Infinity');
I realize this adds significant complexity to Annoyed Tomatoes, where the Tomatoes are supposed to bounce and scale – but not rotate. But, the general idea is this... if you add your own code, you might be able to make it work. Also, if Tumult wanted to improve Physics with Hype, adding this setting seems like low-hanging fruit.