Make the TopDownMovement behavior slide on the obstacles corners

I used the TopDownMovement bahavior to make a Bomberman clone and I make the players slide on the edges of obstacles. I think this can be reused for other games so I would like to make it an extension.

The code is too long to be screenshot, but here the logic:

  • The player moves.
  • For every obstacle in collision, it checks if the player is on the edge and which direction allows to bypass it.
  • If there is no inconsistency on the direction to take, it simulates a key to move in that direction.

The source is in this topic as a PoC (PlayerMovement external events):

But to do so, I would need to access to the obstacles. According to this thread, the feature may exist one day:

The built-in behaviors PlatformerObject/Platform do what I would like to do but this is only possible for bulit-in behaviors, right?

Maybe this is enough common a behavior to be integrated with the TopDownMovement?

I can work on merge request if a maintainer thinks it could be useful.
I’m not really used to C++ and Javascript, but I’m familiar with OOP. This documentation sounds like a good starting point:
https://github.com/4ian/GDevelop/blob/master/newIDE/README-extensions.md

I made a pull request:
https://github.com/4ian/GDevelop/pull/2153

It can be manually tested with this Project:
https://www.dropbox.com/s/vy3obp0u1mb44ew/TopDownObstacleBehaviorTest.zip?dl=1

1 Like

Thanks, I’ve answered on the GitHub PR :slight_smile:

1 Like

The test project export:
https://games.gdevelop-app.com/game-0b358b6d-8685-4393-9685-9f38c0121b25/index.html

It’s possible to do something similar with events (in the PlayerMovement page from Game scene):
https://www.dropbox.com/s/tnvg04bgb2ztfrs/SansFoieNieLOie.zip?dl=1
https://games.gdevelop-app.com/game-2a3158f8-e9a0-4400-b560-298b15422447/index.html

But the version with events relies on diagonals and that may result to some small decelerations (I think that can be solved). I tried to make an extension with the editor but I need to access to the obstacles. Maybe this can be hacked with javascript events?

1 Like