Jump to content

Drag Sprite Body In Air


srikarg
 Share

Recommended Posts

Hello everyone,

 

Is there any way to adjust the drag of a sprite in the air (I know you can do it on the ground)? Right now, when the character in my game jumps into the air off of the ground, it can move horizontally very easily. In other words, the horizontal movement sensitivity is extremely high. Is there any way to reduce this sensitivity and add some sort of drag to the sprite's body when it is in NO contact with any obstacles (i.e. no collisions)?

 

Thanks in advance,

srig99

Link to comment
Share on other sites

The body.drag value reduces the velocity, whether it's in the air or not - it simply reduces the velocity constantly so that the velocity sooner or later returns to 0.

 

You could either disable the ability to change velocity entirely when the character is in the air (remove air control) or you could increase the body.drag.x value when the character is in the air by an amount that feels natural while giving a bit of air control. I guess you could also set the body.maxVelocity.x value to something lower when the character is in the air.

Link to comment
Share on other sites

  • 2 years later...

you can also do the following and set drag to zero, to manually simulate drag when the character is touching down. You can negate the if, or use an else to have separate friction for the air and surfaces, or do a more complex checking if there are different type of surfaces with different friction like ice, grass, air with or without changing wind :)

if (player.body.touching.down) {
    player.body.velocity.x = player.body.velocity.x / 1.1;
}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...