schteppe / cannon.js

A lightweight 3D physics engine written in JavaScript.
http://schteppe.github.com/cannon.js
MIT License
4.71k stars 711 forks source link

Problems with cylinder collision #296

Open gruutak opened 8 years ago

gruutak commented 8 years ago

Hi! First of all I love cannonjs. It made things a lot easier for me. Now, the issue... I'm currently making a bowling game. The game starts with it's spins already on the ally. When I set mass > 0 for my pins, as soon as the game starts they fly all over the place and the ones that fall in the alley get part of the body inside the alley's body. Ball and other objects worked fine. I'm only having problems with cylinders.

What am I doing wrong?

EDIT: The alley was created using CANNON.Box

screenshot_21

jzitelli commented 8 years ago

I'm not sure if it's related to what you are experiencing, but I also had some trouble with cylinders, particularly with contacts on the flat ends. I ended up implementing an implicitly-defined cylinder shape (rather than the current implementation which is based on the ConvexPolyhedron shape) which seems to be working well for me so far - you can find it in my fork (https://github.com/jzitelli/cannon.js)... it only supports cylinder-sphere at the moment but if there's interest I'll work to support some of the other simpler cases (Box, Plane...). If @schteppe is interested I can also set up a PR with the new shape.

gruutak commented 8 years ago

Thank you, @jzitelli. Yeah... I noticed the cannonjs cylinder rotation and already took care of that. I'll try your implementation and give you some feedback.

spacejack commented 8 years ago

@bertZ I did a bowling game with cannon.js a while ago: http://www.spacejack.ca/bowling/

I created my pins using a compound object: one narrow rectangular box for the height of the pin, with a small sphere near the top and a larger sphere near the middle. This gave me a better pin-like shape and physical characteristics.

I also had to spawn the pins a tiny distance (eg. 0.0001) above the ground.

zdying commented 5 years ago

@jzitelli hi. I found that trimester to cylinder collision not working. But I need this. Is there a way to make this works?

Thanks.