Arcade Physics: Is there a way to make a listener on velocity change?

I’m curious if there is a way to listen to a arcade sprite and if the arcade sprites velocity changes (x or y) to perform a callback? Or do I manually have to write something like this with the global event emitter?

example:

var sprite = this.physics.add.sprite('sprite')
sprite.body.on('velocitychange', ()=> //do stuff when it changes)

Can’t you just check the velocity in a Scene’s update function? You could keep track of last frame’s velocity to see if it has changed. If you need an event, you can also perform such a check and emit it manually (with sprite.emit).

1 Like

I could but my game is networked to hell and back and I’ve found doing things with callback pattern a lot easier to handle network traffic with.