physics based on zones?

Hi,

Just a quick query, is it possible to set the gravity at different zones?

ie if we have a landcsape where between x = 0 and x = 100 the gravity is 10. Then between x= 100 and x = 200 the gravity is -10.

Thanks [import]uid: 67619 topic_id: 19539 reply_id: 319539[/import]

I don’t think so, but you could apply a varying, constant force in your gameloop to objects depending on which area of the screen they are in. [import]uid: 93133 topic_id: 19539 reply_id: 75451[/import]

you mean change the physics force depending on which area I was in? The only thing with that is… if there are other elements on the screen… ie other baddies on different parts of the screen they would be affected as well… [import]uid: 67619 topic_id: 19539 reply_id: 75452[/import]

You could pick and choose which objects are affected. Perhaps put all the objects you want to apply the differing forces to in a table, and loop through the table in your game loop checking the location of each object and applying a force based on that.

[import]uid: 93133 topic_id: 19539 reply_id: 75457[/import]

Why not create newRects for each portion of the screen you require and assign a sensor physics body to them.

Then you can do what is required in your collision listener :slight_smile: [import]uid: 84637 topic_id: 19539 reply_id: 75460[/import]