# Creating moving platforms with Blockly

Hi everyone! Here’s a tutorial for making a vertically moving platform. I used this to make the lift in the first level of the VR Adventure Game: https://cospac.es/edu/e6DQ

1. Start with a clear stage. Take a Flex Cuboid from the Building Objects in the Library.

Make it into a platform shape. Duplicate it with alt+click and arrange them so they line up nicely (toggle snapping with s).

Place the third platform up in the air (this one’s 2m up). I changed the colour of the moving one so it’s easier to see.

Label the middle platform “Lift” and press enter. Add it to Blockly.

1. Open the Code panel and select Blockly. Look under “Transitions” and click on this block:

Change the direction of movement to “up”:

Change it to 2 metres up in 2 sec.

Now it will go up once when you press play.

Right click and duplicate your block. Then change the duplicate to “down” and leave the rest the same.

1. Now we need a pause between the movements. Go to the side menu again and open the Control flow menu, and look under “Other” for this block:

Drag it in and change it to 2 sec, then arrange them as so:

Press Play to see if it’s working.

1. Lastly, you need to make them repeat. Look under Control flow again, then Loops, and click on this block:

We want it to loop forever, so instead of typing a number where it says “10 times”, we need the ∞ (infinity) block. Look under Math and it’s the first block:

Place it in the Repeat block and change it from π to ∞.

The finished Blockly code should look like this:

Press play to see if it works.
Done!

Bonus: If you want to make more moving platforms within your scene, they all need to move at the same time. Find the “execute in parallel” block:

and place all your other blocks inside it like this:

Test it out, and everything should move together.

You can find the finished space I made in this tutorial here: https://cospac.es/edu/QBaR

6 Likes