R
Rednavi
Guest
So after working for a while on this I finally managed to almost complete the slope support coding for my platformer action game. The last thing left to finish now is a method to adjust my Y position while walking on the slope (Y position is set correctly while LANDING on it so that's fine). Basically this is what I need help with:
If you're walking on common ground and eventually walk off of it the character will change his state to the falling state as desired, as there's no ground below him. A variable is set to prevent this if you walk on slopes. That way I can freely walk left and right without triggering a falling state while on a slope (And no slopes have a dead end, they always link to common ground). So accidentally falling while walking downhill is not an issue. Now here's the deal:
* I need something that lets me do this through Y position manipulation (So no vertical speed changing. The vsp should stay the same).
* My position when on a slope should always be (position_meeting_rounded(x,y+1,par_slope) so I need a way to enforce this while on a slope. Both when I'm going to be inside of a slope (walking towards an upwards hill) and when I'm walking downhill (Which so far ends up with me on the air).
* I've reserved a variable for when I'm on a slope (aptly named onslope) so this wont conflict with anything else (Like say, trigger a falling state for example. That wont happen).
* If my position does not equal to that, then I need to increase or decrease my y position accordingly in one single frame. All through y position tweaking.
* This has to work while I'm moving on the slope as I've already taken care of setting my y position correctly when walking into a "slope buffer" from common ground and while landing on any spot of any slope. All that's left to solve is the y position while moving ON the slope itself.
* Slope detection uses position_meeting because all I care about whether my character's axis is in x,y+1,par_slope or not, as shown in the pictures. The rest of the bounding box is irrelevant for this. So avoid the use of place_meeting for this.
* Slopes have their collision set to precise and there are 3 basic slope types: The 45 degrees one shown in the pics and two others with 1/2 and 1/4 of that slope's height.
I believe nothing else is really needed right? Let me know if you need any piece of coding for this.
If you're walking on common ground and eventually walk off of it the character will change his state to the falling state as desired, as there's no ground below him. A variable is set to prevent this if you walk on slopes. That way I can freely walk left and right without triggering a falling state while on a slope (And no slopes have a dead end, they always link to common ground). So accidentally falling while walking downhill is not an issue. Now here's the deal:
* I need something that lets me do this through Y position manipulation (So no vertical speed changing. The vsp should stay the same).
* My position when on a slope should always be (position_meeting_rounded(x,y+1,par_slope) so I need a way to enforce this while on a slope. Both when I'm going to be inside of a slope (walking towards an upwards hill) and when I'm walking downhill (Which so far ends up with me on the air).
* I've reserved a variable for when I'm on a slope (aptly named onslope) so this wont conflict with anything else (Like say, trigger a falling state for example. That wont happen).
* If my position does not equal to that, then I need to increase or decrease my y position accordingly in one single frame. All through y position tweaking.
* This has to work while I'm moving on the slope as I've already taken care of setting my y position correctly when walking into a "slope buffer" from common ground and while landing on any spot of any slope. All that's left to solve is the y position while moving ON the slope itself.
* Slope detection uses position_meeting because all I care about whether my character's axis is in x,y+1,par_slope or not, as shown in the pictures. The rest of the bounding box is irrelevant for this. So avoid the use of place_meeting for this.
* Slopes have their collision set to precise and there are 3 basic slope types: The 45 degrees one shown in the pics and two others with 1/2 and 1/4 of that slope's height.
I believe nothing else is really needed right? Let me know if you need any piece of coding for this.