schteppe / p2.js

JavaScript 2D physics library
Other
2.64k stars 330 forks source link

fixed plane acts like a bumper when positioned or created above Y of 0 #225

Closed ken-sands closed 8 years ago

ken-sands commented 8 years ago

When positioning a 0 mass plane, (ie the the ground) if it is set to a y position above 0 then objects hitting it are bounced up with the force of that y position.

To see this, load the ragdoll demo and move the ground up.

do this in the console...

world.getBodyById(13).position[1]=0.1;

or if you want it to dance more!

world.getBodyById(13).position[1]=0.5;

for any y position below 0 it seems fine.

schteppe commented 8 years ago

Sounds like you're trying to move static bodies, which is not recommended. You can set them to kinematic upon creation instead, to be able to move them.

ken-sands commented 8 years ago

Oh sorry no I'm not trying to move them, this issue occurs when they are created in that position. my moving it example was just an easy way show the effect. Set the position in the plane constructor and it still acts as I describe.

ken-sands commented 8 years ago

if you look at the ragdoll html you'll see the plane is created at 0,-1, change the html to

var plane = new p2.Body({ position:[0,0.3], });

and see the issue.

You can create a plane with a y of 0 or any minus amount you like and it acts as expected, but create it above 0 at all and things go funny.

Am I explaining this any better or am I seeing it all wrong?

schteppe commented 8 years ago

Oh, then it's a bug... Will have to debug this. You're using the latest version? Did you run the build on master branch?

ken-sands commented 8 years ago

Yes, latest version from the master branch. Latest build that is. so the 0.71 version.

ken-sands commented 8 years ago

by the way it works fine if it's a box rather than a plane, ie if I use a 0 mass box as my floor I can create it anywhere and it acts as expected just the plane that seems to have the issue.

schteppe commented 8 years ago

Looks like I cannot reproduce this any more. I tried modifying ragdoll.html so that the plane has initial position [0, 0.3]. I think it was resolved.

ken-sands commented 8 years ago

I just tested on https://schteppe.github.io/p2.js/demos/ragdoll.html It's still broken, is that still pointing at an old version of the library?

I'm on chrome on windows, opened that page then in the f12 console i passed world.bodies[11].position[1] = 0.3; to set the ground plane, and it's bouncing all over.

schteppe commented 8 years ago

Yea, the live demos are using an old version. Didn't release yet. Try checking out the project locally, running npm install && grunt and opening demos/ragdoll.html.

I think the problem was that the AABBs didn't update properly. Try pressing the T key and the bounding boxes will get rendered. In the old version you can see that the top edge for the plane is always 0 (due to a bug) but in the master version it matches the plane.

ken-sands commented 8 years ago

Ahhh, yep, seeing that. Cool I'll grab the new version and close this. Thanks.

GuillaumeLeclerc commented 5 years ago

The bug still occurs and I just installed it from npm. Do you know when it will be released ?