• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Vertical (vsp) Moving Platforms

PlayerOne

Member
Finishing off my moving platforms for my project and this one is really giving me a headache.

I have a vsp platform but my player object keeps cliping/falling through it when the platform goes up after hitting a wall. On top of that the game freezes, not crashes, no doubt due to the while statement in the code.

Any help is appreciated.

Code:
//PLAYER END STEP
else if (vsp_final != 0 && place_meeting(round(x),round(y+vsp_final),_wall_vsp))
{
   
   if (place_meeting(round(x),round(y+vsp_final),_wall_vsp))
   {
   
   vsp_carry=_wall_vsp.vsp;
   
       while(!place_meeting(x,y+sign(vsp_final),_wall_vsp))
       {
       y += sign(vsp);
       }
       vsp_final=0;
       vsp = 0;
   }
}
Note that the vsp platform contains collision to reverse its speed and that works fine.
 

NightFrost

Member
The way I do moving platforms (which has worked well so far): I have platforms perform their movement in Begin Step, so they all have moved before player is handled in normal Step. Each platform checks if player is riding them (collision at position y - 1, player is not falling or jumping). If so, the platform adds its own movement to variables on player that track this (call them external_hspd and external_vspd or such). When player Step event runs, controls are read as normal and vspd / hspd are calculated normally, but the external ones are added to them before collision checks start. This way, the collisions receive the total movement player has acquired during the step. At the end of the step the external tracker variables are set back to zero.

There are other ways, such as turning your movement code into generic script that receives instance id and hspd / vspd on call, and performs movement & collision checking. You can then call the function as many times as needed as various influences need to reposition player (or any other entity).
 
Top