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.
    755B3FED-5FD4-4782-B512-E88CD25F2481

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

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.
29

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

Change the direction of movement to “up”:
24

Change it to 2 metres up in 2 sec.
00

Now it will go up once when you press play.
platforms_1

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

  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:
    36

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

Press Play to see if it’s working.
platforms_2

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

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:
46

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

The finished Blockly code should look like this:
12

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:
43

and place all your other blocks inside it like this:


Test it out, and everything should move together.
platforms_executeinparallel

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

6 Likes