Ignore Gravity

0 favourites
  • 8 posts
From the Asset Store
Gravity Square is a game where I aim to reach the square at the polka dot door :)
  • I want some elements to be affected by gravity and others not to be.

    At the moment I am trying to fake gravity by applying a downwards force every tick for the appropriate objects but this is causing some problems. Is there a better way to do this?

    Cheers,

    Mick

  • Are you using physics or..?

    If you post a capx, it'd help us understand the problem better.

  • I was trying this also. Using the physics plugin it seems you can set individual gravity. Though after having used Box2D I thought you could :|

  • Sorry I can't post a cap it's in a massive project :(

    But yeah I'm using physics, world gravity is set to 0 and for each object which I want to be affected by gravity I am applying downwards force to it. It sort of works but when I stack objects or move them around they start to shake and stutter.

  • Ah just tried it. Yeah you're right, it doesn't work.

    What about the setting the Y velocity? I set it to -8.3 and it's so slow it's not noticable.

    Sprite Set Velocity to (Sprite.Physics.VelocityX, -8.3)

    Works nice in my little tester. Don't know if that kind of hack helps in your situation though. But it does stop the shaking.

    Then when you want gravity back, don't execute that event.

  • yeah it is smoother but brings up further problems. Does anyone know how the gravity works in code and if there's a way to reproduce this through events?

  • To keep it working with physics, set velocity is your only way really, apart from apply force which you've tried.

    Sprite Set Velocity to (Sprite.Physics.VelocityX, 9.1) would apply gravity.

    Gravity with events is essentially the same as set velocity, except physics would be messed up (collisions and whatnot).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello Mick,

    Just a thought here, but maybe you could use your current system with some modifications. Maybe stop the downward force when the object collides with another object and apply it only when there is no collision? Or scale the amount of force relative to the object's distance from another object?

    I just started playing with the Physics stuff, so sorry I can't offer specific ideas related to that!

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