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:

I made a pull request:

It can be manually tested with this Project:

1 Like

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

1 Like

The test project export:

It’s possible to do something similar with events (in the PlayerMovement page from Game scene):

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