Rescue the Lunar Lander: A CoderDojo Tutorial

I’m talking about this guy right here.

Part One: Setting Up PlayCanvas

  1. Go to https://playcanvas.com
  2. Press login on the top right. (Make a new account if you don’t already have one)
You can also login using your Gmail account.
(Tip: you can copy and edit any project you see on this website!)
You can give it any name you like!
Click to go into your workspace!
This is the “Launch” simulation button.

Part Two: Adding Gravity

  1. Click on the “Main” scene settings at the top:
This is world’s settings
It’s negative so that it pulls things down

Part Three: Adding Ground

  1. Click on the + button at the top left:
We can add lots of objects this way
A plane is just a thin solid surface
Uh oh! We have to fix that!
Click “Add Component” then “Collision”
This is roughly how it should look
This makes it interact with the physics world
Now it stands!

Part Four: Make It Fly With Code!

Now that you’re familiar with the editor, we’re going to write some code! PlayCanvas uses Javascript.

  1. Right click in the folder area and create a new script:
Right click anywhere in this area to bring up this menu
This will pop up the editor!
//When space is pressed
if (this.app.keyboard.isPressed(pc.KEY_SPACE)) {
//Apply a force on the Y axis
this.entity.rigidbody.applyForce(0, 2, 0);
}
Note how you can add your code to any object!
Click on “Add Script” to bring up a dropdown
NASA approved physics simulation

Challenges!

  • Make the ship fly faster!
  • Make the ship fly to the right when the D key is pressed and left when A is pressed.
  • Create a script to move the camera around.
  • Make the ship rotate when you press space (helpful tutorial)
  • Add more ships!
  • Create an elaborate maze for the ship to go through.
  • Help me create more challenges?

--

--

Graphics programmer working on maps. I love telling stories and it's why I do what I do, from making games, to teaching & writing. https://omarshehata.me/

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Omar Shehata

Omar Shehata

Graphics programmer working on maps. I love telling stories and it's why I do what I do, from making games, to teaching & writing. https://omarshehata.me/