Creators – Simple AI Navigation

Apologies for the late post. This week we looked at simple AI navigation.

The basis of navigation in Unity is the NavMesh. A NavMesh is a simplified view of the game world that marks out all the areas that AI characters can move through. The pictures below show the same scene with the NavMesh made visible in the second:

navmeshoff

navmesh-on

The blue areas are the NavMesh and are the areas that AI characters can move in. The holes made by the walls are apparent as is the  “ramp” on the steps and the circle/arrow combinations where characters can jump down from or across obstacles.

Making a NavMesh

 

The first step in making a NavMesh is marking pieces of the scene as “walkable” and “not walkable”. Open the Navigation panel from the Window menu. When ever this panel is selected, the NavMesh will be displayed in the Scene View, by default.

The Navigation panel has three buttons across the top. Select “Object” and select objects in the Hierarchy that you want to be part of the NavMesh. Select the floor or ground object, select the “Navigation Static” option and set “Navigation Area” to “Walkable”:

screen-shot-2017-02-17-at-11-40-46

Then select each wall/obstacle and again select “Navigation Static” but this time set “Navigation Area” to “Not Walkable”.

Press the “Bake” button in the bottom of the  panel to create the NavMesh.

Adding a Character

We use the AIThirdPersonController prefab from the Unity Standard Assets to test our NavMesh. Adding it to our scene, we find that it has a “AI Character Control” script that takes a “Target” parameter.

Screen Shot 2017-02-17 at 11.44.50.png

Just drag any game object (even an empty one) from the Hierarchy here to tell the character to move to it.

Sample Project

The sample project can be found here. This is in Unity 5.5, so ensure you’ve upgraded to this version before trying to open it. The sample project also contains some logic to reroute the character between an array of targets, alternating when the spacebar is pressed. It also has had some “Off Mesh Links” generated. These allow the character to drop from the elevated platform and to “jump” (more accurately float really with this character) between them.

 

Javascript Intro

Today the Bodgers and Creators were on a hiatus so Mark took a few folks and covered some web development – with a particular focus on Javascript.

We reviewed:

  • How the internet works and how web pages get from the internet to your computer using DNS and HTTP.
  • Talked a bit about the two main kinds of code that our browsers understand:
    • HTML which is great for documents and static content
    • Javascript which is great for dynamic content like animations and games

We then spent the rest of the time playing with Javascript, using the p5.js framework to do some graphical stuff.  We learned about:

  • Functions which is where code is written
    • We wrote two functions: setup() and draw()
    • We called several functions which were written in the p5 framework such as ellipse(..), rect(…), random(..)
  • Variables which is where data is stored.  We learned that in javascript, unlike c# or java, all variables are declared with the “var” keyword.
  • Decision statement which is used to decide between options – in javascript the “if” statement is used for this purpose

We built quite a few cool things to draw interesting patterns and shapes and some of you came up with some mad patterns.  The one we ended up with is shown below.  Have fun playing with javascript and I’ll be really interested to see what you come up with!  Also try to think of ideas and if you come up with something interesting we can have some fun trying to build it!

CoderDojo Athenry Resumes on 21 Jan 2017

happy-new-year-2017s

Happy New Year 2017 from the CoderDojo Athenry mentors!

CoderDojo Athenry resumes on 21 January 2017 (1 week later than usual). We have lots of great tech and coding projects activities planned for 2017.

New members are always welcome, so feel free to bring a friend along. And we have some laptops for loan, so you don’t need to one to join in.

As always, we will be based in Clarin College Athenry from 12:00 to 2pm on Saturdays. More information here: https://coderdojoathenry.org/about/

2016 Christmas Party and Show & Tell at CoderDojo Athenry

This slideshow requires JavaScript.

Here are photos from our Christmas party and Show & Tell day at CoderDojo Athenry on 10 December 2016.

It was really impressive to see the things that our young people had built and created. There was also a great Robot Duels session, organised by mentor Declan in the Bodgers group: Bodgers – Robot Duels At CoderDojo Athenry

We are very grateful to our supporters in the community around Athenry:

  • Clarin College and Principal Ciaran Folan, who are so generous with their space every week
  • Galway & Roscommon Education & Training Board, who provide us with an annual Youth Club Grant
  • Medtronic and Declan Fox, who have provided us with a grant linked to Declan’s volunteering
  • Hewlett Packard Enterprise and Mark Davis, who provide us with loaner laptops
  • Boston Scientific and Kevin Madden, who provided us with the loan of three 3D printers for the semester
  • Supermacs and Joyces, both of whom gave us generous deals on the food for the Christmas party

And of course we are eternally grateful to our wonderful mentors, and to the parents who come along with their children every week. Thank you!

We look forward to seeing you all in the New Year!

slide10

Bodgers –Getting Started with Your Own Raspberry Pi or Arduino

Hi Everybody

This Saturday the Bodgers group looked at some of the tools available to set up and use the Raspberry Pi or Arduino at home. We looked software for formatting SD Cards, some of the SD card images available for the Raspberry Pi, putting images on SD cards, configuring the Raspberry Pi and connecting to the Raspberry Pi.

We also did a quick overview of the Arduino IDE. This software allows us to write and upload software to the Arduino.

You can find the links to the software we used short tutorials on how to use them in my slides from Saturday here pi-and-arduino-tools.

We also took a look at the MagPi Magazine which is the official Raspberry Pi magazine. there are a load of interesting articles in the Christmas issue which is in the shops now or is available for download for free from https://www.raspberrypi.org/magpi-issues/MagPi52.pdf . There are a few nice articles on basic stuff like breadboards and GPIO Zero and there are also some articles on robot sensors which anybody who wants to continue from where we left off with robots will find very interesting.

There is also news of a new programme from the Raspberry Pi Foundation which is aimed at kids that are around the same age as the Bodgers group. The Pioneers is a series of challenges that will roughly last the length of the school term and will be open-ended to allow you to come up with your own ideas. Unfortunately the competition is limited to the UK for now but it will be open to the rest of the world soon. Check out The MagPi for more information.

The MagPi needed to show some examples of what kids can make for the Pioneers article so obviously they looked to CoderDojo Athenry for inspiration :).    capture

CoderDojo Athenry at Minevention

Minevention2016.JPG

Well done to everybody at CoderDojo Athenry who participated in Minevention 2016 in the Radisson Hotel Galway on 26 and 27 November.

Our stand looked great, with the Pi-based games console, a TV showing the Athenry Castle Minecraft model, the Oculus Rift demoing a Unity game, one of the Bodger’s robots, members with their laptops demoing Scratch programs and Minecraft modding, and a 3D printer on the first day.

We were very proud of our ninjas who are fantastic ambassadors for CoderDojo! Thank you for all of your great work!

In addition, thanks very much to Lisa O’Brien and the Minevention team for allowing us to participate, and for inviting me to give a presentation about CoderDojo.

Special Event on 3 December: Dick Baldwin’s Little Sailboats

We will have what should be a very interesting set of speakers at CoderDojo Athenry on 3 December for the second half of the session (starting around 1pm).

Dick Baldwin, a sailor based in Maine, USA, sends 5 foot long unmanned, GPS monitored sailboats out into the sea. Recently, one of the little sail boats, Lancer, arrived in Ireland and was picked up by 8 year old primary schoolgirl Méabh in Leitir Móir, Connemara. Her school hopes to relaunch it next year, with the help of The Marine Institute.

We will have interactive presentations via Skype from Dick Baldwin and Ariadne Dimoulas of the Educational Passages project, and Méabh will come along in person to tell us about finding the boat. In addition, Dr Margaret Rae of the Marine Institute (who is a CoderDojo Athenry mom!) will be on hand to explain more about the project and maybe answer your questions about what the Marine Institute does and how important technology is for its research.

Below is a summary of the presentation. It should be really interesting! Thanks a million to Margaret and the Marine Institute for setting this up.

One never knows what’s going to happen when a small boat goes to sea. This presentation is about sending 5foot unmanned, GPS monitored sailboats out into the sea where every voyage is different and the learning opportunities are great. These little sailboats follow the winds and currents and will sail for months & months often crossing oceans and reporting its position and scientific data along the way. 

A group like yours could equip a boat with an array of scientific sensors to monitor atmospheric and ocean data. You could also include a solar panel and maybe a camera or possibly even add steering capabilities to your boat. Think of the data you could collect and what it would be like when your boat comes ashore in far- away lands. Will you be able to communicate with them and what would you ask them to do with our boat?  Let’s explore the possibilities.

Advancers P5 Week 3: Our first game

Click “Run Pen” followed by “Edit on Codepen” to view the game and play with the code.  At this stage, codepen has been working well for us so I think it’s a really good idea for you all to register for an account on codepen.  This will allow you to “copy” my sketches so you can save your versions of them online.  As we get more advanced (or if the network is down), we will start working locally with Atom again but this is good for us.

Today we started writing our first javascript game.  We thought for a bit about which game might be good to start and decided on a version of the hit game Flappy Bird.  We got quite far before people started to tire!

It will take another session to finish the game – we might do this next week, or take a break from javascript and come back to it in the new year.

Writing the Game

The first step was to plan how we would do the game.  Like all projects, we build it up in steps.  These steps would work to build a basic flappy bird:

Step 1: Draw the sky

Step 2: Draw the ground

Step 3: Draw the bird

Step 4: Make the bird fall

Step 5: Make the bird stop falling when it hits the ground

Step 6: Make the bird jump/flap when the mouse pressed / screen touched

Step 7: Add pipes as obstacles with a random gap

Step 8: Move the pipes towards the bird

Step 9: When the pipes go offscreen on the left, make them appear on the right again

Step 10: Check if the pipe is hitting the bird and restart of it does

Step 11: Add a distance label (how many pipes have we passed)

Step 12: Add sound, improve the graphics and keep a “high” score

We got as far as Step 6.  The next 6 steps would need another week to cover.  I’ve added comments to the code so you can see which parts of the code relate to which steps.  If you have your own codepen account, it might be a good idea to attempt to do the rest of the game – you might get stuck but that’s part of the fun!

New Concepts we covered today:

  • Variables.  Variables in javascript are just like variables in scratch.  The key things about variable are:
    • You create a new variable by writing the word “var” followed by the variable name.  E.g. we wrote the variables:
      • var birdHeight;
      • var gravity = 0.5;
      • Creating a variable by writing the word “var” is called “declaring” a variable.
    • You can change the value of a variable by using “=”
      • birdHeight = 10;
    • You can also use a variable name in assignment, so e.g. we could make the birdHeight 1 bigger by writing:
      • birdHeight = birdHeight + 1;
    • We learned that if you want to be able to see a variable everywhere, we need to declare it
  • Math operators:
    • We learned that some of these are written a bit differently in computer programs:
      • / is how we write “divided by” – e.g. width/2 is the same as writing “width divided by two”.  This is because on a keyboard for some reason there isn’t the ÷ symbol.
      • * is how we write “multiplied by” e.g. 2 * 2 is the same as writing “two multiplied by two”.  This is because x is very easy to confuse with lowercase x.  So if you had a variable called x things would get confusing!