quickb2 collision + applyimpulse

Hello, I'm having some trouble with the collision listening, this time in a different way.
I'm trying to create new objects once my object has been hit too hard (like pieces of it), and for some reason, if I create them through the listening event, they turn out static.
I've seen that no matter what object I create there, it turns out static, but if I create it out of the event, it's normal.

Also, I wanted to know how could I apply an impulse in some direction, because as I can see, if I apply an impulse on an object in-air, it just gives it some torque, and it won't move until it'll hit something. Is there a way to make something "jump" in some direction in mid-air?

Thanks a lot,
Tamper
The first issue is (was) a bug. Thanks for finding it! I've fixed this in the latest version on SVN.

Make sure you're applying the impulse at the object's center of mass. If it's not at the center, it will make the object spin.
I found the problem with the ApplyImpulse(), it didn't do anything actually, because I am creating a shape, and not a body, and I looked at the source, and apply impulse only does something if it has a quickb2 body, or a box2d body, and because it was a shape it did none....
Should I start using bodies instead of shapes?
I'm using the qb2Stock.newRectShape(), should I use body? What's the difference between those?

Tamper
tamper wrote:
I found the problem with the ApplyImpulse(), it didn't do anything actually, because I am creating a shape, and not a body, and I looked at the source, and apply impulse only does something if it has a quickb2 body, or a box2d body, and because it was a shape it did none....
Should I start using bodies instead of shapes?
I'm using the qb2Stock.newRectShape(), should I use body? What's the difference between those?

Tamper

http://www.kerp.net/box2d/displaylesson ... &lesson=20
Tamper, question for u, how are u skining your shapes? Can you post sample code?
Artofacks1, thanks for the video, but I do know what the difference between those is, I just don't know how they're represented differently in the engine, as in why using one would be better than another.
I am creating multiple boxes which all have 1 shape, so what would be the difference to create them as a body, or as a shape?
And sorry, I didn't quite understand your question, what do you mean shining?

EDIT: Okay, I seriously found the problem now, it's a bug (I think).
In the source, when using ApplyImpulse, the engine checks whether the shape has a body (box2d, or quickb2), and normally, a shape will have one of those...
But because it is created once again in the contact listening, for some reason, it is created without a body, so the apply impulse doesn't do anything!
Could this be just another bug in the contact listening?
I saw that if I create that class (which contains the shape) outside the contact listening, the apply impulse works fine! 🙂

EDIT2: After some more testing, I saw that the shape gains the body only after it is added to the world, is that true?
This edit doesn't affect my other one though 😛

Thanks,
Tamper 😀
Good work finding that bug. That should be pretty easy to fix...I think I will simply add applyImpulse to the set of functions that are delay-called when made inside a contact listener.

Thanks!
Tamper I meant skin your shapes.
applyImpulse() bug (not working inside contact listener on an object created/added inside the same listener) is fixed in latest SVN revision. Thanks again for finding that.

Original thread: https://box2d.org/forum/viewtopic.php?t=6796