This still won't be perfect, but it'll stop the speed doubling. If neither the left or right keys are being held It's when you start running at diagonals that things get bizarre. He even slides along large circles once he reaches a certain point on the circle. if you run towards an edge, it behaves exactly the way I want it to. I want to be able to say "When you're holding Left and Right and you hug the corner, speed = speed/2." Maybe I'll have to make the wall hugging code a variable, and then say "If wall_hug_diagonal, speed = speed/2."įor the most part, it works great. However, if I'm holding two directions, the game takes THAT speed, PLUS the speed of the wall hugging, so he kind of whips around the edge for a moment. Right now, if he hits the edge, he'll start moving along an axis at his speed. My current code is all for when you're going down, up, right, or left INTO the edge of something.but when you go in at a diagonal in the opposite direction (hard to articulate.may have to illustrate), things get funky.Ģ.) My guy still whips around corners. If this was a real game, I suppose I would want to have different "wall hugging" behaviors on other objects - people for instance (where maybe I don't want such forgiving wall hugging behavior).Įdit: I've toyed with this for the past hour but still can't figure out how to resolve some issues.ġ.) My guy keeps getting stuck on the corner of things. Since I'm just kind of doing testing, I have this as a parent to a couple of different objects. This is just a parent object that all of my 'walls' inherit (which at some point I suppose would include invisible tiles behind things like couches, tables, etc). What I suppose would further complicate things is that this is all just code as it pertains to my par_wall object. It's also been a bit tricky to figure out ![]() I suppose the obvious workaround would just be that objects would have to be of a certain size for these commands to work. ![]() The trouble now seems to be coming in with:Ī.) Skirting around circles (the behavior for whatever reason seems to work best on square objects or objects with square sprite/collision masks).ī.) The character doubles in speed if the player is holding a diagonal at an object edge, because it's taking speed from both the direction behind held AND the wall hugging code.Ĭ.) Right now it's having trouble for some reason with objects that are too small. If there IS a wall in front of him, AND if there's a place free at a steep diagonal (the, the character moves along the wall until the path is clear. My character moves unless there's a wall in front of him. It's actually kind of working the way I want it to, though I'm sure this isn't the most efficient way of doing this. If place_meeting(x-speedup,y,par_wall) & place_free(x-12,y+wall_buffer) y+=speedup //If there's a wall to the left AND there's a space free below and to the left, move down. If place_meeting(x-speedup,y,par_wall) & place_free(x-12,y-wall_buffer) y-=speedup //If there's a wall to the left AND there's a space free above and to the left, move up. If !place_meeting(x-speedup,y,par_wall) x-=speedup //If there's not a wall to the left, move left. "wall_buffer=20 //The number of pixels my character is to the edge of an object. Well I played around with things a bit more and feel like I almost have something that's about what I'm looking for. If !place_meeting(x-speedup,y,par_wall) x -= speedup Īm I going about this all the wrong way? Should I use a place_free command instead, and figure out some way to say "if the distance from X to the nearest available path is free, move the character along X until the path is free"? Like I said: If I could have my character slide to the nearest avaible path (if I'm close to the edge of something, of course).ĭoes anyone know of a way to accomplish this? Is it simple? My current code in my character's step event looks like this: I'd love to have something more forgiving. ![]() However, if I'm running by some block, and I'm just a pixel off, my character will stop dead in his tracks. I can hold two directions and my character will slide up a wall or object. Running along or past walls and objects is pretty forgiving and you never really get "stuck" on anything.Ĭurrently, I feel like I've been able to get my character in Game Maker to walk and run into walls or objects. This will also happen if he trys to run along walls that are oddly shapped in general. You know when you play Chrono Trigger, and Crono runs past the edge of a wall or table? He kind of slides to the nearest available path and keeps on going. I've posted this in a couple areas, but I'm still struggling with it.
0 Comments
Leave a Reply. |