Keyboard Movement Sliding

Started by EliasFrost, Wed 23/10/2013 19:02:37

Previous topic - Next topic

EliasFrost

Hi! I'm having a slight problem with the standard keyboard movement module, when I walk towards walkwable areas, the character stops when it collide with it instead of sliding along the wall like in most games. I have absolutely no clue how I could possibly make that work, or if anyone have gotten it to work in past. If by any chance there is a way to make the character slide along the walkable areas, it would be awesome if someone could point me in the right direction.

Thanks. :)

Khris

This is much harder to implement than it may seem.

The first issue is that the standard keyboard movement module uses built-in walking, while that kind of sliding would require handling all the walking yourself (as in, place and animate the character manually).
The other thing is that sliding like this usually needs to know the angle of the edge. After all, it would look pretty weird if the character slid along a wall that's almost perpendicular to their walking direction. Since walkable areas are pixel based, you are facing the old "how to turn pixels into vectors" dilemma.

I once implemented this, but it was for a tile engine, and my walkable area edges were only horizontal, vertical or 45°. Even still, it was a huge pain to do.

The basic idea is this:
-assuming the character is walking straight to the right, go up and down a few pixels from their position and check how the walkable area continues near the edge that was just hit (by going left and right from there)
-come up with an algorithm that will turn this point data into a line
-decide at which point the angle allows sliding
-if it does, move the character along the edge

The first implementation will usually break as soon as the character hits "not nicely shaped" edges, like walking straight onto a tip, with the blocking area retracting on both sides.

The other option is to implement an algorithm that turns the entire walkable area(s) into a vector path and use exclusively that to handle the walking. Entire papers have been written on this...

Snarky

#2
The gesture recognition module includes code for turning a pixel trace into a vector path. Might be possible to use that (though first you have to find the outline of the walkable area).

Edit: I guess I'm talking about this one. Whatever Cat was using for her kanji game that she showed off at Mittens.

Daniel Eakins

Bernie has a fully functional keyboard movement module which does sliding. Its collision detection routine doesn't detect characters due to a long-standing bug in AGS, but otherwise it works perfectly.
We all have our time machines, don't we?

EliasFrost

Thanks for all the answers, I will look into all suggestions and I'll see how well I do. Thanks :)

SMF spam blocked by CleanTalk