Prevent tunnelling on drag

Discuss issues specific the Javascript port of Box2D
LeeMc
Posts: 2
Joined: Tue Dec 18, 2012 4:28 am

Prevent tunnelling on drag

Postby LeeMc » Tue Dec 18, 2012 4:45 am

Hi guys

I'm quite new to Box2dweb so still getting the hang of it all but theres 1 thing I can't quite figure out.

I'm creating a pool game, when the user has cueball in hand I allow them to drag it to wherever they want on the table. When this drag happens I set the object balls to static so that there are no collisions, however the cueball still tunnels into them - and if you let go of the mouse when this happens both the cueball and object ball move.

Is there anything I can do to stop this? Just a general nudge in the right direction would be much appreciated.

Thanks
Lee

irresistible force
Posts: 1988
Joined: Tue Jun 24, 2008 8:25 pm
Location: Tokyo
Contact:

Re: Prevent tunnelling on drag

Postby irresistible force » Wed Dec 19, 2012 10:25 am

The ball you are dragging is a dynamic body? Dragging it with a mouse joint?
As long as you destroy the joint before returning the other balls to dynamic I would expect it to be ok. Maybe you need to run the simulation for a few timesteps after releasing the dragged ball to make sure any slight penetration has been corrected.

LeeMc
Posts: 2
Joined: Tue Dec 18, 2012 4:28 am

Re: Prevent tunnelling on drag

Postby LeeMc » Thu Dec 20, 2012 1:24 am

Hi

Yes the ball I'm dragging is dynamic and using a mouse joint, sorry I should have stated that in my previous post.

Thanks for your reply, it certainly lit a lightbulb and I've managed to get it working now! Thanks alot.

Lee


Return to “Javascript”



Who is online

Users browsing this forum: No registered users and 1 guest