You are on page 1of 16

Computer Games Design | Computer Games Programming

UNITY PRACTICAL

Applicant Day Taster Session | Contact: ct@glos.ac.uk

For more information about the course visit ct.glos.ac.uk

Like us on Facebook, follow us on Twitter and subscribe to YouTube,


search for uogct
Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

1 Start Unity and create a new


project.

Select Game Object > Create


Other >Terrain

Make sure the terrain is


selected.

Press F to focus the terrain in


the scene

2 Click and change the


default width and length of
2000 to 200 and set the
height to 50
3 Select and set the
height to 50 – click Flatten
This will set the base height
so that the bottom of the
terrain will be below sea level
4 Go the Inspector and select
the raise/lower terrain tool –
note the different types of
brushes available.

5 Note that the opacity slider


equates to the strength of the
brush, lower the value for the
brush to have less an effect
on the terrain
6 Experiment with the terrain
creation tools – draw terrains
around the edge to start

If a hill gets too high hold


down the shift key and paint
over it

© University of Gloucestershire Page 2 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

7 Progressively add more detail


use different types of brushes,
sizes and opacity levels

8 Hold the shift key and paint to


push the ground down below
sea level

9 Select the paint height tool –


note the height setting

This tool is useful for painting


pathways through mountains
at a set height. Either
manually set a height or shift
click an area to set it

10 Paint a path through the


mountains

© University of Gloucestershire Page 3 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

11 Select the smooth height tool


paint over any jagged edges
that are too harsh to smooth
them. Look at the base of
slopes in particular.

12 Go to Assets > Import


Package > Terrain Package
and click Import

13 Click the paint texture button

then choose Edit


Texture and click select –
browse for Grass Hill and
click Add
The terrain will now have this
material applied to it.

14 Add several more textures to


the terrain

© University of Gloucestershire Page 4 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

15 Using various brushes, sizes


and opacity settings paint
your terrain

16 Got to Assets > Import


Package > Tree Creator, click
import.

Select the Place Trees button,


click Edit Trees and choose
Add Tree.
Browse for the default palm
and select Add

17 Paint trees onto your


landscape

Hint: zoom in close to the


terrain before painting.

© University of Gloucestershire Page 5 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

18 In the hierarchy select the


Main Camera, choose Game
Object > Align with View

19 The scene appears too dark –


go to Game Object > Create
Other and choose Directional
Light

Rotate/position light so that


the scene looks better

20 Go to Assets > Import


Package > Skyboxes and
click import.

Add a sky to the scene by


selecting Edit > Render
Settings

Browse for a
Skybox
material
and select
Sunny 3

21 Your scene should look


something like this

Save your project

© University of Gloucestershire Page 6 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

22 With the terrain selected


choose the Paint Details icon

Click Edit Details > Add Grass


Texture and browse for Grass

23 Zoom close into a flat area


and paint the grass texture
onto the terrain

24 Press play – the grass


probably moves too fast
Stop the game and select the
terrain settings
Dial down the wind
speed and size
25 To improve performance it is
possible to bake shadows into
the scene

Go to Window > Light


Mapping

Choose Bake and set the


Mode to Single then click
Bake Selected

Save the scene if prompted

The bake will take sometime


– a thumbnail preview will
appear when it is completed –
this one took 20seconds

26 Go to Assets > Import


Package > Water Basics and
click import.

In the Project tab expand the


stand assets > Water and
drag a Daytime Simple Water
to the scene

© University of Gloucestershire Page 7 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

27 Position and size as required

28 Go to Assets > Import


Package > Character
Controllers. Drag a first
person controller to the scene

Position your view of the


scene using ALT and mouse
then select Game Object >
Align with View (make sure
you do not deselect the
controller

29 Press play and navigate the


level you have created.

Expand the Movement


parameter and increase the
max forward speed to 12 –
you will be able to run faster

Save your scene.

© University of Gloucestershire Page 8 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

30 Once you have a terrain


extend the level by adding
some assets using the Asset
Store
Select Window > Asset Store
(CTRL + 9)

Pressing it will launch the In-


Built Unity Explorer for the
Asset Store. This may take a
few seconds to load.

31 Once launched – maximise


the window

This Asset Store front page


will be different each day.

32 In order to download FREE


Assets from the store, you
must register and using the
Log In button at the top right.
33 An account has already been Username: ct@glos.ac.uk
set up for you – use the
Password: Asset123
details on the right to log in.
34 Go back to Unity and you
should find that you are now
signed into the Asset Store.

In the search field, type


“Simple Medieval House”

© University of Gloucestershire Page 9 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

35 The Search Results should


bring up a list of assets
available to download.
Click the Simple Medieval
House, by Achonux

36 On clicking the asset, more


details will appear including
the package contents.
Click Download / Import to
begin downloading the asset
and importing it into your
current project.

37 After downloading, Unity will


present the Importing
package dialogue box.

Ensure All the assets are


ticked and click Import.

Once the Unity has finished


importing, close the Asset
Store window.

© University of Gloucestershire Page 10 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

38 After importing navigate to the


SimpleMedievalHouse folder
and drag a copy of the Model
on to the terrain and near
your character

39 Select the House and add a


Mesh Collider to stop the
player from walking through
the building

Select House > Component > Physics > Mesh


Collider

40 Click GameObject > Create


Other > Cube

Resize the cube so that it


resembles a platform.

Add a material to it.

Name the platform Lift.

© University of Gloucestershire Page 11 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

41 Click GameObject > Create


Other > Cube

Place near the House

Resize the cube so that it


resembles a support column.

Add a material to it.

Name the cube stand.

42 Click GameObject > Create


Other > Sphere

Resize and position the sphere


so that it resembles a simple
button.

Add a material to it.

Name the sphere button.

43 In the hierarchy drag button


and stand onto Lift.

Click Window > Animation.

Ensure Lift is selected in the


hierarchy

© University of Gloucestershire Page 12 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

44 Press the record button and at


the prompt save the new
animation as UP

45 Click Add Curve > Transform


> Position

Click on Transform Position.y

46 Ensure there is a key frame at


0

47 Position the play head at 1


second and drag the lift
upwards in the scene to 5 units
high (or change the value y
position in the inspector)

Note – use CTRL or CMD 6


to bring back the animation
window.

48 Click on the UP label and


select create new clip – save
as DOWN
49 Press record and set a key
frame a 0 – move the Lift in
the Y axis to 5.

© University of Gloucestershire Page 13 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts

50 Move the play head to 1


second and move the lift in the
Y axis to the ground level.

Close the animation window.

51 Remove the Animator


component from the Lift

52 Add an Animation component


to the Lift

Component > Misc >


Animation

Ensure the inspector matches


the image
53 Create a new JavaScript file
called Lift and add this code
private var pressedButton : boolean = false;
private var isLiftUp : boolean = false;

to it and attach it to the button var target :GameObject;


(remember to add comments
to the script). function OnMouseOver()
{
pressedButton = true;
(Note: this file is already }
included in the project)
function OnMouseExit()
{
pressedButton = false;
}

function OnMouseDown()
{
if (isLiftUp == false)
{
target = GameObject.Find("Lift");
target.animation.Play("UP");
isLiftUp = true;
}
else

© University of Gloucestershire Page 14 of 16


Applicant Day – Using Unity
Tutorial: Terrain and scripting lifts
{
target = GameObject.Find("Lift");
target.animation.Play("DOWN");
isLiftUp = false;
}
}

function OnGUI()
{
if (pressedButton == true)
GUI.Box(new Rect(300,300,200,20), "Press
button");
}

54 Save the script and drag it


onto the button

Also drag the Lift parent onto


to the target parameter.
55 Set the Animation UP clip
asset to legacy.

To do this:

Select UP asset

Inspector > Select Menu >


Change from Normal to
Debug
56 Change Animation Type from
2 to 1

57 Repeat the same for the DOWN animation clip

58 Test the game.

© University of Gloucestershire Page 15 of 16


Software covered on the courses:

• Adobe CC (2D asset creation)

• Photoshop, Illustrator, Flash, After Effects, Premiere,


InDesign, Audition

• Autodesk Entertainment Suite (3D asset creation)

• 3DS Max, Mudbox, Maya, Motionbuilder

• Game Engines

• Unity & Unity Pro

• UDK & Unreal

• Cry Engine

• Visual Studio, Java, C#

Hardware available to use on the courses:

• PC & iMac • Latest / Legacy consoles

• Dedicated render farm • Audio recording facilities

• Large screens, twin screens • Green screen facilities

• Touch screens • Motion capture

• Graphic tablets • Arduino kits

• Game controllers • 3D printers

• Smart phones • 3D & 4K TVs

• iPad/Nexus tablets • Cameras

• Oculus Rift Dev Kit 2 • Quadcopters

© University of Gloucestershire Page 16 of 16

You might also like