Box2D problems

I’m trying to apply a force to bring an object (the egg) up. However, I don’t know why the egg rotates too much, so when it lands on a straight horizontal static wall, it continue to roll left or right. I want to apply force, so when the egg lands, it stop immediately (may bounce, but not roll). Here is how I apply the force:

[lua]egg:applyForce(0, -220, egg.x + egg.contentWidth / 2, egg.y + egg.contentHeight / 2);
– Or
egg:applyForce(0, -220, egg.contentWidth / 2, egg.contentHeight / 2);[/lua]

And please explains how the bounce works. If the egg has bounce = 0.3, the wall has bounce = 0.6, so what is the bounce value applys when the egg collides the wall? [import]uid: 103204 topic_id: 18808 reply_id: 318808[/import]

may be u should try setting linear velocity to 0 before giving the force

u may also try something like this
[lua]egg:setLinearVelocity( 0, 0 )
egg:applyLinearImpulse(0, -10, egg.x, egg.y) [/lua] [import]uid: 71210 topic_id: 18808 reply_id: 72430[/import]

Set angularDamping to a really high value - that will stop egg from rotating excessively.

Edit: “Really high” is relative, try 1 and then 10 if it’s too little. [import]uid: 58849 topic_id: 18808 reply_id: 72539[/import]

Thank you renvis@technowand. It works perfect!

@me7: It’s not a good solution, because at other time, I need to roll the egg too. Thank you for your reply, anyway. [import]uid: 103204 topic_id: 18808 reply_id: 72580[/import]

And please explains how the bounce works. If the egg has bounce = 0.3, the wall has bounce = 0.6, so what is the bounce value applys when the egg collides the wall?

And answer this question please.

One more problem: I use transition.to to move my static walls, but the egg don’t move with them, so it falls when the walls move off. How to “stick” the egg with the wall as soon as the egg lands on it? [import]uid: 103204 topic_id: 18808 reply_id: 72602[/import]

To stick the egg to the wall you could use a joint [import]uid: 84637 topic_id: 18808 reply_id: 72952[/import]