Setting up A Basic Scene in Unity

Similar documents
Game Design Unity Workshop

Game Design Unity Workshop

Tutorial: Using the UUCS Crowd Simulation Plug-in for Unity

Pong in Unity a basic Intro

Game Design Unity Workshop

Google SketchUp/Unity Tutorial Basics

Workshop BOND UNIVERSITY. Bachelor of Interactive Multimedia and Design. Asteroids

IAT 445 Lab 10. Special Topics in Unity. Lanz Singbeil

Damaging, Attacking and Interaction

Workshop BOND UNIVERSITY Bachelor of Interactive Multimedia and Design Beginner Game Dev Character Control Building a character animation controller.

UNITY WORKSHOP. Unity Editor. Programming(Unity Script)

Adding a Trigger to a Unity Animation Method #2

Introduction to Unreal Engine Blueprints for Beginners. By Chaven R Yenketswamy

Unity3D. Unity3D is a powerful cross-platform 3D engine and a user friendly development environment.

Auto Texture Tiling Tool

Unity Animation. Objectives. Animation Overflow. Animation Clips and Animation View. Computer Graphics Section 2 ( )

STEP 1: Download Unity

Dice Making in Unity

This lesson introduces Blender, covering the tools and concepts necessary to set up a minimal scene in virtual 3D space.

UV Mapping to avoid texture flaws and enable proper shading

3dSprites. v

Week 1 The Blender Interface and Basic Shapes

Demo Scene Quick Start

Creating a 3D Characters Movement

Auto Texture Tiling Tool

Burning Laser. In this tutorial we are going to use particle flow to create a laser beam that shoots off sparks and leaves a burn mark on a surface!

Creating the Tilt Game with Blender 2.49b

Plotting Points. By Francine Wolfe Professor Susan Rodger Duke University June 2010

Textures and UV Mapping in Blender

Quick Start Guide to using Light Converse along with Pangolin LD2000 and BEYOND

Basic Waypoints Movement v1.0

Game Design From Concepts To Implementation

An Approach to Content Creation for Trainz

Project 2: 3D transforms and Cameras

Unity Game Development

Tutorial: How to create Basic Trail Particles

Unity Scripting 4. CS 491 / DES 400 Crea.ve Coding. Computer Science

The University of Nottingham Second Life Building Tutorial

[ the academy_of_code] Senior Beginners

Assignment 4: Flight Simulator

Easy Decal Version Easy Decal. Operation Manual. &u - Assets

COMS W4172 : 3D User Interfaces Spring 2017 Prof. Steven Feiner Date out: January 26, 2017 Date due: January 31, 2017

Creating Hair Textures with highlights using The GIMP

To build shapes from scratch, use the tools are the far right of the top tool bar. These

Dungeons+ Pack PBR VISIT FOR THE LATEST UPDATES, FORUMS, SCRIPT SAMPLES & MORE ASSETS.

Caustics - Mental Ray

Airship Sub & Boat Tutorial. Made by King and Cheese

Planet Saturn and its Moons Asset V0.2. Documentation

Mobile Touch Floating Joysticks with Options version 1.1 (Unity Asset Store) by Kevin Blake

Tutorial 4: Texture Mapping Techniques

A Guide to Autodesk Maya 2015

CGS 3220 Lecture 13 Polygonal Character Modeling

MIXED REALITY (AR & VR) WITH UNITY 3D (Microsoft HoloLens)

Extract from NCTech Application Notes & Case Studies Download the complete booklet from nctechimaging.com/technotes

Cláudia Ribeiro PHYSICS

Introduction to Windows

Cloth Simulations. 9.2 Physics - Cloth Simulations

SketchUp. SketchUp. Google SketchUp. Using SketchUp. The Tool Set

Blender Lesson Ceramic Bowl

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2013

Tutorial. Creating activities in Expert mode

Creating joints for the NovodeX MAX exporter

Mechanic Animations. Mecanim is Unity's animation state machine system.

This allows you to choose convex or mesh colliders for you assets. Convex Collider true = Convex Collider. Convex Collider False = Mesh Collider.

BONE CONTROLLER ASSET VERSION 0.1 REV 1

Quick Start Tutorial

Documentation for Flash Project

Transforms Transform

Clickteam Fusion 2.5 Creating a Debug System - Guide

XTviz Perth Demo User Manual. What we do

TUTORIAL: MoveYourRobot with Unity3D You created your own robot with servo- motors and you are wondering how to control it.

DOING MORE WITH EXCEL: MICROSOFT OFFICE 2010

PRINT A 3D MODEL PLANE

Chapter 19- Object Physics

-Using Excel- *The columns are marked by letters, the rows by numbers. For example, A1 designates row A, column 1.

Tutorial Physics: Unity Car

Unity introduction & Leap Motion Controller

Tutorial 3: Using the Waveform Viewer Introduces the basics of using the waveform viewer. Read Tutorial SIMPLIS Tutorials SIMPLIS provide a range of t

Terrain. Unity s Terrain editor islands topographical landscapes Mountains And more

Meet the Cast. The Cosmic Defenders: Gobo, Fabu, and Pele The Cosmic Defenders are transdimensional

VISIT FOR THE LATEST UPDATES, FORUMS & MORE ASSETS.

if(input.getkey(keycode.rightarrow)) { this.transform.rotate(vector3.forward * 1);

SketchUp Quick Start For Surveyors

QUESTIONS ACTIONS IN GAMEMAKER

Spell Casting Motion Pack 5/5/2017

Shadows in the graphics pipeline

Blender Notes. Introduction to Digital Modelling and Animation in Design Blender Tutorial - week 1 The Blender Interface and Basic Shapes

Hi. I m a three. I m always a three. I never ever change. That s why I m a constant.

Transforming Selections In Photoshop

VirMuF Manual V 0.5 1

2.2 - Layouts. Bforartists Reference Manual - Copyright - This page is Public Domain

SPRITES Moving Two At the Same Using Game State

MAYA; AN INTRODUCTION TO MAYA; EndOfLine.info;

Dialog XML Importer. Index. User s Guide

Tutorial: Camera basics

Tutorial: Making your First Level

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

8K Earth, Moon and Mars Shaders Asset V Documentation

CS248 Lecture 2 I NTRODUCTION TO U NITY. January 11 th, 2017

Actions and Graphs in Blender - Week 8

Transcription:

Setting up A Basic Scene in Unity So begins the first of this series of tutorials aimed at helping you gain the basic understanding of skills needed in Unity to develop a 3D game. As this is a programming and logic focused course, we will be using free, premade Assets and art available from one of many store. A list of these such places can be found in a later section of the tutorial but the asset store is always a good place. So, let us begin, we ll assume by now you have setup Unity, if not, see the tutorial setting up Unity, this will also explain all the key points needed. The beginning Set up a new empty 3D project, name it what you wish. In the empty scene we re going to first learn how to add various objects into the scene. To keep things simple we re going to just use some basic primitives for now. Basic shapes that are used to represent things in game whilst we develop it. First of all, the floor, we have two choices, a plane or a cube. A plane is a flat shape that would be perfect, however, we do have to be careful, a plane is only visible from one angle, front on. For this reason we ll use a flattened cube for our starting point. We ll assume you know the very basics of Unity controls (if not, see the setting up tutorial again). Make a new cube appear (GameObject->3D object -> Cube) and position it at (0,0,0) with scale (40,0.1,40). Rename it ground by clicking the box next to the tick, this at the moment looks like a flat thing to balance on, but what is needed is something to stop you falling through. That s the job of the collider which is added by default. We ll talk more about colliders later but essentially they make the object physical nothing can pass through it, they also generate events when things bump into them. Material Gains At the moment it s all very grey, let s fix that with some materials, materials are components added to every mesh in Unity to change their appearance. They can be textured or just coloured, often this is imported from your 3d modelling program but we re going to just colour our meshes for now to give them some contrast. In project window, right click and go to create->material. This creates a new material for you to use, select the material and click once on it s name to change it, call this one Black. If you look in the inspector the view to the right should be present, click on the colour next to Albedo and change the colour to black. That s it for the material, to attach it click on the ground and drag the material you just made onto the very bottom of the ground. You should see the icon change, release it and it should change the material on the object to the new one.

Our Player We re going to create a player representation- in this case we ll use a capsule, create a capsule just like you did the cube (but choosing capsule) and position it at 0,2,0. Name the capsule Player, we re going to use a feature of Unity called a Character Controller to control our Player. This contains some built in functionality for physics, collisions and movement, useful. To add it, choose Add Component->Physics->Character Controller. Whilst you re at it, remove the capsule collider. We re going to make a third person style game but it s easy to switch to first person, click on the camera in the scene and drag it onto the capsule. Like this screenshot; You ll want to move the camera around, select it and move it into an appropriate place, you do that like any other object, you want an over the shoulder view. Create a new C# script called PlayerMovement and open it (double click) and get ready to add some code. (You add a script like you add a component). Input in Unity uses Axis, the value can be either -1 or +1 depending on how far it s pressed/ hard it s pressed. For instance, a joystick full forwards would be +1, a back key held down would be -1. We ll talk about configuring them later but Unity has a bunch of built ins based on agreed norms, like WASD being for movement. Basic Movement Here we create a script that gets the input from the user and combines it with a few variables to move around. Here we set up a number of variables. We store the character controller attached to the object. We have variables for things associated with jumping. And with moving around, note that h and v will be used to capture input. In Start, all we do is grab the character controller using GetComponent. Update, which is called every frame, is what we use to check for input and control movement. First we get the value of h and v and save them, we do this using the Input class. This contains

helpful utilities for getting input such as GetAxis and GetButton. In this case Axis and Button are predefined by Unity (we can overrule them if we want though), you can see these in Edit->Project settings->input within Unity. By default Unity binds the horizontal axis to A and D and Left and Right arrows on keyboard and the left stick on a joystick. We use this data to form a Vector3, a vector describes the direction you are moving in 3d space as well as the amount. So, a vector of 1,0,2 would be moving with speed one in a rightwards manner and speed 2 in a forwards manner but not moving up at all. So, we take two vectors, direction we are moving then the velocity- the direction with some extra speed added. Moving on from this we need to do some checks to deal with if we re off the ground. If (charcontroller.isgrounded) means use a built in check of character controller to check if the character is on the ground. If it is, we check to see if the jump buttons pressed, if we didn t check, we d end up being able to jump forerver. Here we just set the yvelocity to be equal to the jump speed so we are jumping. If it s not, we set yvelocity to equal gravity so we re falling. Then we merge the yvelocity we ve just set into the velocity overall so it is included. Velocity and vectors and how they work are not something explained too fully here, it s very Maths based if you want to find out more. Finally, we pass this velocity to the charactercontroller to tell it how fast to move and which direction, we use Move a built in function of the character controller to do this. We times it by Time.deltaTime to make the game move and play similarly at any frame rate since Update() runs every frame. Try it, WASD to move, jump is space. Looking Around So, we can move forwards and backwards side to side and we can jump, but what is missing is the ability to look around. For this we ll use mouse controls, Unity already has an axis setup to access mouse controls, MouseX and MouseY for left and right and up and down respectively. Create a new script, LookX ;

We setup a variable, this time the field is serialised using [SerializeField], we do this so we can see it in inspector. This sensitivity allows us to adjust how fast we turn. In Update, we access the transform component (we don t need to use GetComponent here we can just use transform, little t is that transform, big T all transforms). We want to rotate around the y axis and nothing else, this lets us look left and right, (picture it, rotating around something that goes upright). To do this we check what the mouse value is using Input again if you move it left it ll be minus, right, it ll be plus, because Vectors are X,Y,Z we leave X and Z are 0. We times the amount moved by the sensitivity to give us some element of control of the speed. Attach the script to the PLAYER and try it. A word on transform Transform is a component like any other in Unity, it contains information about the position of the object, the rotation of the object and the scale of the object. It can be accessed like any other component. Any of these can be local or global, global is it s position, rotation or scale in the scene, local means it s position rotation or scale compared to it s parent. A parent is the object it s attached to (e.g. the Player capsule is the parent to the camera above). Looking Up and Down Now you can look left and right, but you can t look up and down, this time we re going to create a LookY script.

This is slightly different from the lookx, much longer for a start, that s because looking up and down needs a few more considerations, you can t for instance turn your head all the way around up and down. We setup four variables here, the sensitivity and the minimum and maximum values we want to allow, 30 degrees either way is a good amount. Then the variable to store the rotation which we ll use later. Like before in update we will get the MouseY value which works the same as before, note that += means add it to whatever the value already is. It s like saying rotationy= rotation+ whatever we re adding. Underneath we use a built in C# function, Mathf.Clamp, this takes three parameters, the first is the value to clamp and the next two are the minimum and maximum. It basically says if the variable is below the minimum set it to minimum, if it s above, set it to max. Finally we feed this all back in, we use localeulerangles to get the angles as degrees we re used to. This time we rotate around X, the Y value should be whatever it is already. We also attach it to the camera, NOT the player, this is because if we attach it to the player, it s whole body will rotate, not something we want. Challenges 1) Add a skybox to the scene 2) Change the ground to a terrain map (note you can change the terrain size in settings->resolution) 3) Pretty up the ground a little to make it look more realistic, 4) Import other assets into the scene (various websites and asset store are good places to get them a list will be on moodle) 5) Switch the view to a first person view (this means moving the camera, think about how you d do this)