How do I change world gravity using a variable

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi All,

    I have just started exploring C2 and have made a small clicker game. I am trying to get the world gravity to change over time using a timer that adds to a variable and checks that variable.

    It doesn't seem to work and I'm not sure why. I have tried using a function and calling it from the ontimer and it also doesn't work.

    As well as this, the physics properties for the baloon tend to make no difference when changed (eg. density, elasticity etc.)

    Any advice.


    CAPX attached:!AkmrWgxeuxlKrhP9BXNTenCw7EMl

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Your event #10 is one condition. It will never work because the GravityTimeMultiplier variable can't be 1, and 2, and 3 etc. at the same time.

    Each condition should be in a separate event:

    event 10:

    GravityTimeMultiplier=1 Set gravity to 2

    event 11:

    GravityTimeMultiplier=2 Set gravity to 5

    And so on.

    If you want all new balloons to be created with the same physics properties, you need to set them in editor on that balloon sprite that you have outside of the layout. It's a "default" instance for balloon object, and all new instances, when created, will be copied from it.

    You don't see any difference in density and elasticity because they are only visible when physic objects interact with each other or with immovable objects.

  • Thanks dop,

    Stupid me, of course, still wrapping my head around the events structure. That solved the first problem.

    As for the physics properties with the balloons. I have been changing them from the editor and the balloon sprite. As you click on a balloon in game, multiple balloons are spawned and each collides and interacts with the other. However, the density and elasticity seem to have no effect? Are you saying that the same physics object will not interact correctly with itself?

  • If you set density=5 to one balloon and density=0.1 to another, and let them collide, you'll notice that the lighter balloon will bounce away much harder.

  • OK, Thanks

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