Is there a way to detect a body start moving?

Hi,
I need to detect when b2Body start moving, what is the best way?

now I have to cache the last speed in my loop.
Code:
for(loop){

    if ((self->body->getLinierSpeed().x != 0 || self->body->getLinierSpeed().y !=0) &&
      self->priviousSpeed.x ==0 && self->priviousSpeed.y ==0){

    //Start moving code;

    }

    self->previousSpeed = self->body->getLinerSpeed();
}


Is there some kind of listener already in box2d?
Qdapps wrote:
Is there some kind of listener already in box2d?

I don't recall there being anything of that sort in Box2D (if there is though, I'm sure someone will mention it).

In any case, your current solution seems perfectly reasonable and is probably how I would do it as well (although I'd probably use a 'speed threshold', rather than comparing the velocity to the zero vector as you're doing).
Jesse wrote:
Qdapps wrote:
Is there some kind of listener already in box2d?

I don't recall there being anything of that sort in Box2D (if there is though, I'm sure someone will mention it).

In any case, your current solution seems perfectly reasonable and is probably how I would do it as well (although I'd probably use a 'speed threshold', rather than comparing the velocity to the zero vector as you're doing).

Thank you for your answer, I will try a threshold.

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