Suggestion: Physics angle of gravity

0 favourites
  • 11 posts
From the Asset Store
Gravity Square is a game where I aim to reach the square at the polka dot door :)
  • Hi,

    I would like to suggest adding a "Set angle of gravity" option to the Physics behaviour, just as the Platform behaviour has.

    I know there is the workaround of setting Physics gravity to 0, then creating a tick event where a force is exerted in the direction of whatever angle you want on an object. This is pretty impractical to add to every single instance you have on screen, and I feel that a Physics angle of gravity function would be quite beneficial to the program and a lot more convenient for game creators.

    -Rob

  • "Set angle of gravity" does exist though

    Unless you mean in general, in which case what you can do is create a family of all the objects you want gravity to be applied to, and then set the angle of gravity of that family.

    Edit: ah I miss read you the first time. However what you could do is make a family then apply the platform behavior to everything and turn off player control.

    Edit2: or not because you cant control platform behavior of families haha silly me

    Edit3: oh hold on, so apparently you can apply behaviors to the families themselves.

    So what you can try is put everything you want to change gravity of into a family. Apply the platform behavior with default controls turned off to that family. Then add an event that sets the angle of gravity of that family. Hopefully that works.

  • Suikama

    Thats not true physics though.

  • Suikama

    That's not a bad suggestion with the families. I'm going to try and alter this idea a bit.

    And you're right, the "Set angle of gravity" does exist for the PLATFORM behaviour, but I need it for the PHYSICS behaviour.

    But thanks for your input, it's always appreciated.

  • Just set world gravity to 0

    Put every object that is affected by gravity in a family with the physics behavior

    And apply a constant force at the angle you desire

    Cheers !

  • Constant force doesn't give realistic physics.

    World Grav = 0

    Gravity Var = 0.2

    Apply force to family = Object.Mass*Gravity Var

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Suikama

    That's not a bad suggestion with the families. I'm going to try and alter this idea a bit.

    And you're right, the "Set angle of gravity" does exist for the PLATFORM behaviour, but I need it for the PHYSICS behaviour.

    But thanks for your input, it's always appreciated.You can use both physics and platform behaviors at the same time though. Just have platform apply to the family and physics apply to each object individually.

  • Whiteclaws

    Yes, the apply force thing does work, but as AnD4D pointed out, it doesn't yield a realistic result.

    AnD4D

    I'm not quite sure how your method is from simply applying a force. Could you please explain it?

    That works, but it unfortunately does not give the effect I'm looking for.

  • Set world gravity to 0

    Set a global variable called "Gravity" and set it to 0.2.

    Give the object the physics behaviour.

    Event - Every Tick

    Action - Apply force at angle

    Angle = whatever you want, let's say 270 for fun.

    Force = physics.mass*Gravity(variable)

  • If you just use force and have multiple objects of all different sizes, the small objects will move faster. The mass*gravity expression ensures they all move the same speed, which is what happens in reality.

  • AnD4D

    I have tested this method thoroughly, and it seems to be doing the trick quite well. I can't find any errors with it so far, and the physics behaviour seems to be accurate. Thanks for that.

    I still stand by my opinion of adding the "set angle of gravity" function to the Physics beahviour of the Construct 2 engine. It's just another improvement to the program.

    As far as this thread goes, however, I think this issue can be closed as AnD4D has provided a functional and elegant solution.

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