Spectre216
Member
So for the past few days I have been trying to get moving platforms to work in GameMaker Studio 2. Started by following Shaun Spalding's tutorial (1 way platforms and moving platforms). I also have some acceleration and deceleration of my character that might be causing my issue. Was hoping to get a second pair (or 3 or 4) of eyes on it. When my character lands on the platform they slowly accelerate off even though my push variable gets set to 0 after being applied to my movement variable. Maybe it is just an order thing, but I can't figure it out despite trying to google and draw out the issue. Any insight would be greatly appreciated.
Player accel/decel code
Player fix fraction movement
//Fraction Code
Player accel/decel code
GML:
//What way walking
var move = key_left + key_right;
//Are we trying to move?
if (move != 0) {
//Can you move
if (canMove) {
//Accelerate
if (xMove != 4*move) {
xMove += move*playerAccel;
}
if (onGround) {
//Animate player
sprite_index = spr_pc_walking;
}
} else {
xMove = 0;
}
//Slow down
} else if (move == 0) {
if (xMove > 0) {
xMove -= playerDecel;
} else if (xMove < 0) {
xMove += playerDecel;
}
if (canAttack) {
//Animate player
sprite_index = spr_pc_stand;
}
}
//Fraction Code
GML:
//Fraction Code
xMove += xMoveFrac + xPush;
xPush = 0;
yMove += yMoveFrac;
xMoveFrac = frac(xMove);
yMoveFrac = frac(yMove);
xMove -= xMoveFrac;
yMove -= yMoveFrac;