So, like I said i'm still pretty new to Box2D, mostly just been fiddling with the examples, but a few questions cropped up in doing so. My main question is about the ApplyImpulse and ApplyForce functions, since they seems to operate similarly, at least parameter-wise. Anyway, heres the situation: I simply took the Hello World example and stripped out all the bodies except the ground and a single box. When i click the box I apply an impulse... simple. Problem being, regardless of the values i pass to applyImpulse the results seem somewhat random almost. I'm just trying to have the box pop straight up. Heres what i have so far:
private function onApplyImpulse(e:MouseEvent)
{
m_testBody.WakeUp();
m_testBody.ApplyForce(new b2Vec2(0, 2000000), new b2Vec2(m_testBody.m_position.x, 700));
};
I'll also mention that the density of the box is 3.0 and the gravity for the scene is 300. Not sure if those values are really out of whack, maybe thats why such a large impulse value is needed? Any suggestions as to common values you've found success with are welcome.
Also, when i use its X position there it seems to not work at all. When this says "applies an impulse to a point" is it asking for a directional vector (which would make sense and what ive run into in other physics engines) or is it asking for an arbitrary point in space relative to the world? relative to the rigid body? If it is a point in space, does it then apply the force along the direction from that point to the center of mass of the Object?
Lastly, should the force to lift the object off the ground be a positive Y force? or negative? the positive number seems to be the only value that results in any type of action (X values seem to do nothing), although negative makes more sense to me. I realize its all probably because of the random assortment of numbers i've been throwing in, so thats why im here, heh. Any help would be appreciated, code snippets would endear you to my heart forever, haha. In all seriousness though, thanks for your time.
-dh
private function onApplyImpulse(e:MouseEvent)
{
m_testBody.WakeUp();
m_testBody.ApplyForce(new b2Vec2(0, 2000000), new b2Vec2(m_testBody.m_position.x, 700));
};
I'll also mention that the density of the box is 3.0 and the gravity for the scene is 300. Not sure if those values are really out of whack, maybe thats why such a large impulse value is needed? Any suggestions as to common values you've found success with are welcome.
Also, when i use its X position there it seems to not work at all. When this says "applies an impulse to a point" is it asking for a directional vector (which would make sense and what ive run into in other physics engines) or is it asking for an arbitrary point in space relative to the world? relative to the rigid body? If it is a point in space, does it then apply the force along the direction from that point to the center of mass of the Object?
Lastly, should the force to lift the object off the ground be a positive Y force? or negative? the positive number seems to be the only value that results in any type of action (X values seem to do nothing), although negative makes more sense to me. I realize its all probably because of the random assortment of numbers i've been throwing in, so thats why im here, heh. Any help would be appreciated, code snippets would endear you to my heart forever, haha. In all seriousness though, thanks for your time.
-dh