How do I keep physics gravity while resizing a sprite?

  • I've looked all around and don't understand why gravity stops working when a physics object gets resized.

    This capx I made has one event. If you disable it the sprites fall like a normal physics object would. Any ideas? Is this a bug or is this just how physics objects work? I'm using r239.

    https://dl.dropboxusercontent.com/u/19590484/resizing%20physics%20objects.capx

  • See Ashley's response here to a similar problem reported as a bug. Every time you change animation frame, or resize an object (as in your case), the physics body inside the physics engine has to be replaced.

    [quote:2yka3vxj]The Physics behavior treats a change of frame as destroying the physics body and teleporting a new one in its place (to take in to account changing collision poly, size, origin etc). Therefore animating objects keeps destroying the physics body you're applying force to.

  • Hey thank you for pointing me in the right direction.

  • Use a placeholder (invisible sprite) to keep the physics and your sprite as an image only.

  • Any recalculation of the collision polygons (sine, scaling, animation) will give you a memory related java error, when physics is used, anywayz.

    Depending on how many affected objects, the error pops up in 1 minute or 20 minutes later.

    Try it, give the objects in your capx a sine (on size) behaviour. Empty event sheet.

    Try

    ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can also save the velocity and angular speed to variables before setting the size and setting the velocty from the variables after.

  • R0J0hound

    I tested his capx with your excellent Chipmunk Physics as engine. The objects fall and collide while resizing. Even with a sine behaviour (size) attached. So it works flawless as one would expect.

    But now, after your suggestion, i doubt my suggestion. Does Chipmunk has the same (or other) problems with recalculating polygons ? (As in animations by instance)

  • It's just an alternate idea of one doesn't want to use a third party behavior. Chipmunk does also recreate the shape but the velocity is retained. There isn't a crash if you do it continuously. All the old shapes should be cleaned up by the garbage colllector.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)