Hello!
I am trying to code a moving platform, however, it sometimes (not always) glitches into place and just...stays there shaking (not touching the walls or anything it might be colliding into).
I would like to know what could be causing this in the codes.
CREATION:
STEP:
horizontal_speed, position_from and position_to are variables set on the Variable Definitions inside the room.
It seems pretty simple coding and pretty straightforward but I can't seem to understand why it gets stuck by itself sometimes
I am trying to code a moving platform, however, it sometimes (not always) glitches into place and just...stays there shaking (not touching the walls or anything it might be colliding into).
I would like to know what could be causing this in the codes.
CREATION:
GML:
randomize();
dir = choose (-1,1);
STEP:
Code:
x += horizontal_speed * dir;
if ( x <= position_from or x >= position_to){
dir *= -1;
}
It seems pretty simple coding and pretty straightforward but I can't seem to understand why it gets stuck by itself sometimes