Jump to content

P2 Body velocity ignored after state change


keke
 Share

Recommended Posts

Hi,

When changing from one state to another any updates to a p2 body's velocity seems to be ignored. 

I've created the following codepen to illustrate:

http://codepen.io/klas/pen/qbMXmm

When changing from FirstState to SecondState (with clearWorld = false ) the player sprite stops moving when using p2 physics even though velocity is still applied in the update function in SecondState. If I change to Arcade physics everything works as expected and the player sprite keeps moving. Maybe I'm just missing something how p2 physics work? Is there some kind of reset needed between states? I've tried re-enabling p2 physics for the player sprite in the Second State with no luck.

Update: If I call revive() on the player sprite in the create function of SecondState it seems to solve the issue. Not sure why that is?

Updated codepen: http://codepen.io/klas/pen/VeGMpq

Thanks

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...