Movie-style shotgun blast (sticky collision) with Box2D
I'm making a Flash game where the player throws balls of mud at objects in the sky. I'm using Box2D to model the physics. I don't want the ball to bounce off of objects (apply a normal force); instead I want it to impart its momentum on the object it开发者_JS百科 is striking (like a movie-style shotgun blast).
I've tried tweaking friction and restitution, but nothing has given the effect I want. It looks like I'm going to have to work at a more gritty level, but I wanted to see if someone has a solution before I possibly reinvent the wheel.
If your trying to make the objects in the sky take the momentum of the mud and have the mud lose little momentum, just give the mud a large density or give the objects in the sky a lower density. Use the b2BodyDef.density property. Hope that helps!
Create a weld joint to join the objects after the collision. You'll need to create a contactlistener to accomplish this.
精彩评论