How to change x position of sprite without using body.move (P2 physics)

I want to move a sprite directly to the left/right by changing it’s x position. When i use moveLeft it does a smooth animation, but i want it to move instantly. How do i do this? I’ve tried changing sprite.world.x but that does not work.

Hi @mariusfranzen,
You need the method body.reset(x,y).
Regards.

1 Like

This almost works. Using body.reset also resets the sprites alive property. So if I kill a sprite which then moves it will be alive again.

Edit:
I solved this by only reseting the sprite if it’s alive.

if (sprite.alive){
    sprite.body.reset(x, y);
}