In order to keep a player “stuck” to the ground.
As it stands, I get contact when the player lands, determine the distance ratio for the vertex the player is on.
The issue is, when crossing to the next vertex, the player will go into an airborne state (or just follow the same path walking through the air).
I’ve looked to how others have handled similar problems, and it seems to be one of those that people keep close to the vest.
I figured there are three possible ways to tackle the issue, and while I try to implement these (or the one that works best), I was hopeful that others might be willing to give some insights into which might be best, or if these are not well thought out. (I wouldn’t bother asking if it weren’t for the limited time I get to work on the game).
Anyway;
option 1: When I loading the map polygons, get the vertex that would be walk-able, get the start and end points for that vertex loaded into an array.
This would wind up with an array of point vectors and when the player exits the current vertex it would grab the next point to determine the direction of the vertex.
The foreseeable issue with this is to determine whether the polygons are actual neighbors with a common start point or if its a gap in the terrain that would lead to a drop.
option 2: Would be to explicitly define, in an array of arrays of points that would define the ground segments, when the player lands on a segment of ground it would figure out which array it belongs to and if they go past the first or last point in that array that they would drop (unless its a wall).
This is a more brute force approach, and would probably be tedious to define, perhaps I could use custom properties in tiled to define that…
option 3: I would keep the polygons for collision detection, but then, use polylines over the walk-able terrain, then it seems it would be simple to get the next points once the player goes beyond the current line segment.
The only issue I have with this is it seems a bit redundant.
Well, as I was writing this, it seems clear to me now that option 3 is going to be the best bet and the simplest to implement, so I’ll try that one first…
any comments on these approaches is still appreciated though, so I’ll post it anyway.
Thanks, from the neighborhood novice.