A problem concerning gravity

Hello everyone

I’m new to corona and I have a problem I hope someone can help me with.

I attached a picture for more demonstration, the problem is when the player walks over the grass it keeps walking and does not fall even if there is no grass under it altgough I did set a value for gravity:
   

physics.setGravity(0,9.8)

and the player body type is dynamic, the grass is static.

this problem occurs only if the player walks and a straight line but if dropped from a higher place into the empty space it falls with no problems.

Hi @mm1403163,

As a first test, can you enable “hybrid” draw mode so we can see where the actual physical bodies are?

[lua]

physics.setDrawMode( “hybrid” )

[/lua]

Once you do, please post another screenshot.

Thanks,

Brent

Hi Brent,here is the screenshot

okay I solved it my self after reading more about draw modes and testing them,

the problem was that the player body becoms “sleeping”

  • gray — a body that is “sleeping” due to lack of activity.

I don’t really know why this happens, but if any one is intrested the solution was to use this line

physics.start( true )

instead of this

physics.start()

to start the physics engine, which “Prevent all bodies from sleeping”.

thanks a lot :slight_smile:

Hi @mm1403163,

That’s a little odd… normally, once a sleeping physics object has any interaction (collision) with another body, it will “wake up”. Your non-sleeping approach is valid though, however you might consider applying that property to only the player (not globally to all objects) by setting its “.isSleepingAllowed” property to false:

https://docs.coronalabs.com/api/type/Body/isSleepingAllowed.html

Brent

Hi @mm1403163,

As a first test, can you enable “hybrid” draw mode so we can see where the actual physical bodies are?

[lua]

physics.setDrawMode( “hybrid” )

[/lua]

Once you do, please post another screenshot.

Thanks,

Brent

Hi Brent,here is the screenshot

okay I solved it my self after reading more about draw modes and testing them,

the problem was that the player body becoms “sleeping”

  • gray — a body that is “sleeping” due to lack of activity.

I don’t really know why this happens, but if any one is intrested the solution was to use this line

physics.start( true )

instead of this

physics.start()

to start the physics engine, which “Prevent all bodies from sleeping”.

thanks a lot :slight_smile:

Hi @mm1403163,

That’s a little odd… normally, once a sleeping physics object has any interaction (collision) with another body, it will “wake up”. Your non-sleeping approach is valid though, however you might consider applying that property to only the player (not globally to all objects) by setting its “.isSleepingAllowed” property to false:

https://docs.coronalabs.com/api/type/Body/isSleepingAllowed.html

Brent