Moving Platform issue.

F

FrontalArrow302

Guest
OK so im like a few weeks into developing n learning how to code....somewhat.....i im doing good so far but now im stuck on the collisions for a moving platform i decide to add in. i was watching GameMaker Casts video on moving platforms and i got as far as making the platform move left to right....but when i comes time to add in the collision code.... the platform just freezes and the player still falls through....i tried tweaking the code slightly( kinda sorta don't know what i did lol) and the platform just vibrates vigorously and the player slowly falls thorugh like he's standing on quicksand. Any ideas on what i should do....something im not doing? Thank you!

This is the create event for the Platform
randomize();

direction = choose(-1,1);

hsp = 1;
vsp = 0;
grv = 0.1;
walksp = 2.5;


The beginStep event
x += hsp * direction;

if(x <= position_from || x >= position_to) {
direction *= -1;
}

AND THIS IS THE COLLSION CODE FOR THE PLAYER WHICH HE COPIED INTO THE PLATFORM STEP EVENT AND GOT HIS COLLISIONS BUT THAT ISNT HAPPENING FOR ME

//Horizontal Collision
if (place_meeting(x+hsp,y,wall1))
{

while (!place_meeting(x+sign(hsp),y,wall1))
{
x = x + sign(hsp);
}

hsp = 0;
}


x = x + hsp;

//Vertical Collision
if (place_meeting(x,y+vsp,wall1))
{

while (!place_meeting(x,y+sign(vsp) ,wall1))
{
y = y + sign(vsp);
}

vsp = 0;
}


y = y + vsp;
 
S

Slothagami

Guest
The vibrating platform might be because position_from and position_to are to close together, if they are too close it will just turn over and over again and vibrate

Also make sure that position_to is greater than position_from, position_from should be the leftmost side that platform goes, and position_to should be the rightmost position otherwise it's always less than position_from AND greater than position_to so it flips it's direction every step.

I've had this same problem many times before, it's always been one of the two solutions, not sure about the Collins yet though, it might fix when the vibrating is fixed.

EDIT: better explanation.
 
Last edited by a moderator:
F

FrontalArrow302

Guest
The vibrating platform might be because position_from and position_to are to close together, if they are too close it will just turn over and over again and vibrate

Also make sure that position_to is greater than position_from, position_from should be the leftmost side that platform goes, and position_to should be the rightmost position otherwise it's always less than position_from AND greater than position_to so it flips it's direction every step.

I've had this same problem many times before, it's always been one of the two solutions, not sure about the Collins yet though, it might fix when the vibrating is fixed.

EDIT: better explanation.
Ok thank you I’ll try it out sorry for the late reply
 
Top