• 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!

Legacy GM Platformer Errors...

Hello everyone! I am making a platformer game and it is working really well so far, but I was trying to the player move with a platform that is under him (when it was also moving) and got it to work. The only problem is sometimes it works and sometimes it doesn't. I'm not sure why but most of the time when you land on a moving platform you move with it, but other times you will stay still even with the platform under you. Here is my code, hopefully you can find my error:
Player:
Code:
if(!place_meeting(x,y+1,objMovingObjects)) {PatformDir = 0} else {
hSpd = hSpd+PatformDir
}

if(!place_free(x+hSpd,y)) {
while(place_free(x+sign(hSpd),y)) {
x += sign(hSpd)
}
hSpd = 0
}
x += hSpd
Moving Platform:
Code:
hspeed = dir
if(place_meeting(x,y-1,objPlayer)) {PatformDir = dir}
 
My suggestion is to have the platform itself move the player directly, instead of passing a value back to the player to handle it later. Most likely what it happening is that when the platform detects that it needs to move the player, by the time the player sees that it need to move because of a platform, conditions have changed.
 
My suggestion is to have the platform itself move the player directly, instead of passing a value back to the player to handle it later. Most likely what it happening is that when the platform detects that it needs to move the player, by the time the player sees that it need to move because of a platform, conditions have changed.
Thank you! I rewrote most of the code inside of the moving object and now it works perfectly!!
 
Glad to hear! Good luck with the rest of your game! As a bonus, with the code to move things in the platform, you can easily extend that code to carry other types of things too, be it enemies or items or whatever.
 
Top