Jump to content

Partial collision with a ground


nomolosvulgaris
 Share

Recommended Posts

I'm developing an arcade game (2d platformer) with enemies moving like this:
http://codepen.io/anon/pen/FytIg?editors=011
Everything looks fine, but the enemy tends to fall down when the ledge is too short for completing enemy's way (you can see what I mean by uncommenting the only commented line in my code). It's not what I want. So I find a way to bind a callback on the "moves-to-the-edge" event. Maybe to figure out if the collision with ground is only partial. This event might also be helpful to activate a "panic animation" for player staying at the edge (like in Sonic The Hedgehog). How can I do this? The only solution I can think out is to wrap the enemy with invisible bodies to check whether they are blocked from down on each step. But is this the only solution?

Link to comment
Share on other sites

This 'edge of platform detection' has been covered a few times, so I'll direct you to the relevant posts where the discussion takes place:

The basic options are either to have some way of detecting the edges dynamically, or putting invisible markers or 'bumpers' at the edges of each platform which turn enemies around before they fall off. Camps are divided over which method is best, but it depends entirely on the game you're making.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...