0
votes

i expect this is quite an easy one.

I'm trying to simulate a falling Bean Bag that can be knocked into a net on one side of the screen.

I have: a dynamic body and circle shape representing a hand or bat, which moves respective to the mouse. falling dynamic body circle shapes representing the Bean Bags. and simply, two small circle shapes representing the net's open top.

To move the hand/bat i update a linear velocity on each step, so that this force can be applied to the bean bag:

// move hand
deltaX = (handBody.GetPosition().x * scaleF) - mouseX; 
deltaY = (handBody.GetPosition().y * scaleF) - mouseY; 
var newVel:b2Vec2 = new b2Vec2(-deltaX, -deltaY);
handBody.SetLinearVelocity(newVel);

My problem is that I would like the Bean Bag to absorb some of the initial force of the knock. At the moment it's too easy for the falling bags to be flung off the screen with a quick swipe. Is there a simple way to use the friction, damping or other settings? I have tried but cannot seem to create the effect. Can anyone suggest how i can remove some of the collision force manually without effecting the updated position of the bat/hand?

tia, Chris

1

1 Answers

0
votes

Can't you just multiply the new velocity/bean bag velocity with say 0.8 or whatever and call this the dampening effect?

But the provided code seems weird, I can't see anything in it related to impact or hitting a bean bag. This just sets the vel of hand?