Hot do i apply custom gravity?

0 favourites
  • 3 posts
From the Asset Store
Rpg action of Neves is a complete template to apply your story to create your world.
  • Hello! I'm using physics and i want to apply gravity only to some objects, leaving other with 0 gravity.

    I know that this topic has been answered hundred times before and I know that I should set world gravity to 0 and apply 10Y force to desired objects, HOWEVER that doesn't seem to work. 10 force seems WAAAY too much + gravity seems to ignore objects' masses. I tried applying 0.10 force, but it still doesn't feel right.

    Edit: Plus when using forces, objects can't sleep

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • To address the mass not being taken into consideration:

    Force = mass * acceleration

    The units with the physics behavior is off by a factor of 50 or so. In practice that only matters if you want to use exact units. Most of the time you can just tune the numbers.

    There is no solution for the sleeping with what the physics behavior provides access to. If you can somehow access the underlying physics engine from JavaScript there may be a way to do it, but the behavior wasn’t designed for that, and you’d be fighting with the behavior.

  • Okay, thanks to R0J0hound I've figured it out!

    To set set one objects's gravity to 0 we don't mess with world's gravity. Leave it whatever it is.

    Just apply this to an object:

    Apply force:

    X = 0

    Y = Object.Physics.Mass * -Current world gravity (default 10) / 50

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