moving platforms up & down | gml
Add a new object objMovingUpDownBlock use the same sprite as the objBlock and set parent:

Again, if you need a wider platform, make a wider sprite (don't stack objMovingUpDownBlock objects side by side):

code for step event | gml
Updated 2025: Simply add the following code to STEP event in vertical moving platform:if place_meeting(x,bbox_top-1, objPlayer){ //height cap: if y > (ystart - 200){ vspeed = -1; objPlayer.y += vspeed; } else { vspeed = 0; } } else { //return to start: if (y < ystart) { vspeed = 1; } else { vspeed = 0; } }
The code above should be all you need, works in conjunction with Platform Collision Correction code (first lesson)
You can also adjust the instances of the platforms individually in the room editor using the creation code...

... but the quickest way of adjusting instance variables in the room, allowing you to reuse objects quickly:


Challenges
1. Implement the above code2. Adjust the
move_speed
and range
variables. How fast and far can this go that is feasible for general gameplay (for the 'average' gamer)?3. Set out a new level with moving platforms using the skills you have learnt so far. Make it increasingly challenging to get from one side of the room to the other (with timed jumps etc.)
4. Make an elevator using this knowledge. Give the elevator an on / off switch or trigger (difficult).