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:
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”:
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.
Just drag any game object (even an empty one) from the Hierarchy here to tell the character to move to it.
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.
In the CoderDojo Hackers Group these days, everybody is working on their own projects in groups, such as building computers, designing robots, and carrying out all sorts of top-secret plans!
Here are couple of photos from 11 Feb:
Thank you all for coming yesterday on such a lovely day.
This week we did a simple Piano.
We only had to draw two keys, and then could duplicate these and change the names. The same applied to the code. The code is the same for each key apart from one small change so the note is the appropriate for the key.
REMEMBER! You need to make four changes each time you duplicate:
Change the name of the spite to the next Note
Change the name of the TWO costumes
Change the NOTE played
Remember, no sessions for the next two weeks. Have a nice break and for anyone with confirmations to attend next week I hope the weather is extra nice for you.
See you back on the 4th of March
Here are notes from this week in PDF cda-s6-week-4-17-piano.pdf
- 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
- 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(..)
Today we took a look at Paint.net, which is a drawing program. I quickly went through the menus but the best way to learn a program like this is to use it and experiment with it.
The main reason we looked at it this week was because we will need it next week as we begin our modelling and stop/motion animation. After we take our photos we will be able to “clean them up before we bring them into Scratch as our Sprites.
Next week, if the Moms and Dads could bring along a camera or phone along with the lead to attach these to your laptop.
And of course most important of all bring your imagination!
Here the full notes from todays session in PDF form. cda-s6-week-2-17-learnaboutpainting.pdf
This week we looked at the Environment asset pack and the creation of terrains.
Terrains are, at their core, nothing more than a grayscale image (shades of black & white) where the colour values are interpreted as representing heights. Black is is interpreted as zero height, white is interpreted as maximum height (as defined in the terrain’s properties) and every shade of grey in-between represents an intermediate value. The terrain editing tools provides brushes in a variety of shapes to raise or lower the terrain as desired.
Terrains in Unity don’t just allow us to define their heights. They also allow the painting of the terrain with a combination of different textures. In the Environment asset pack there are a selection of useful textures for painting a natural looking environment. These are a grass texture, several rocky textures and a sand texture.
Trees and grass are also enclosed in the Environment asset pack. These are also painted onto the texture with a brush, or in the case of trees, autofilled to a requested total number.
Once we had our terrain built, we added a character controller from the Controllers asset pack to enable us to walk around in it. We finished the session experimenting with the water prefabs that come with the Environment pack.
Please note that I won’t be at Dojo next Saturday (4th Feb 2017). Nonetheless, you are welcome to attend and join another group for the day if you wish to do so.