Closed r3curs10n closed 9 years ago
A constraint is probably the best and easiest way to attach to the mouse, if you want the bat to rotate around the mouse pointer.
Your problem is that the bodies move through each other during a time step because they move too fast. Possible solutions are:
Thanks. Making the line thicker seems to be the best option. Using CCD considerably slows the simulation.
Ok. I was kind of expecting that slowdown. Perhaps it's a tad faster now, after I added some raycasting optimizations.
A side note: if you're calling the step function like this: world.step(1 / 60)
then you should switch to this: world.step(1 / 60, timeSinceLastCalled, maxSubSteps)
. This will make the simulation keep up with the wall clock. See http://schteppe.github.io/p2.js/docs/classes/World.html#method_step
I have a body (Line shape) that I have constrained to move with the mouse pointer using a RevoluteConstraint. This body is supposed to work like a baseball bat. Sometimes (usually when the mouse is moved quickly) it misses collisions with ball objects.
Is using a RevoluteConstraint the best way to accomplish what I'm trying to do i.e. making a body move with a pointer?