Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Keeping momentum box2d — Gideros Forum

Keeping momentum box2d

Hello!
I have a box2d object which is falling. I have to destroy it and replace it with another one. But that's not the problem. The problem is when I create the new body, it doesn't have the momentum the last body had. And when I say momentum, I basically mean the speed with which my first body was falling. How can one get that value and set it to another body?

Also, the part where I delete the body is necessary so I can't avoid that. Any ideas?
Thank you in advance!
Tagged:

Comments

  • hgy29hgy29 Maintainer
    Accepted Answer
    You could use b2.Body:getLinearVelocity to get the previous speed and set it to the newly created body.

    Aside from this, why must you absolutely destroy the old body ?

    Likes: misterhup

    +1 -1 (+1 / -0 )Share on Facebook
  • It has to do with the fact that I am manipulating it's size but that is not the only reason. It does make my approach the most flexible though, so that is why I want to keep that in. If I were to keep the same body, it would make messing with it's dimensions harder and it would affect other aspects of the app that deal with it's position in relation with another dynamic bodies. Pretty tough to explain, and english isn't my native language so that's why I phrased my question that way. I apologize for any confusion :#

    And thank you! Got it to work with LinearVelocity!
Sign In or Register to comment.