Make the TopDownMovement behavior slide on the obstacles corners


#1

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


#2

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


#3

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


#4

The test project export:
https://games.gdevelop-app.com/game-6c672edd-157d-4674-8d78-ab3c26bcf1dd/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?