0

So I have something going on that's confusing me, involving a body not moving. I used the SetLinearVelocity() member function on a body, like so:

dude.body.SetLinearVelocity(new b2Vec2(0.1, 0.1));

I then place a console.log() right before calling the Step function:

console.log(dude.body.GetPosition().x);
console.log(dude.body.m_linearVelocity);
world.Step(1/60, 10, 10);
console.log(dude.body.GetPosition().x);

This is in my game animation loop, so the console.log gets called over and over. It says m_linearVelocity is a b2Vec2 with an x value of 0.1 and a y value of 0.1.

So right before the Step function call, the the x and y values of m_linearVelocity are greater than zero, but there is never any change in dude.body.GetPosition().x from the beginning of the above snippet to the end.

I don't know where to start in tracking down the problem, because this makes no sense to me. Does anyone know why this might happen?

edit: I should add, it worked when there was gravity, but in zero gravity, it won't move, even though the linear velocity is greater than zero.

John L.
  • 1,903
  • 2
  • 13
  • 15

1 Answers1

0

Found the answer to my own question. However, instead of the WakeUp() function in the example, I need to use SetAwake(true):

http://www.box2d.org/forum/viewtopic.php?f=8&t=3181

John L.
  • 1,903
  • 2
  • 13
  • 15