TRANSCRIPTEnglish

Learn Unity and C# Programming (2024) | 5h Unity 2D Course | FREE Unity Tutorial

4h 35m 45s39,634 words6,412 segmentsEnglish

FULL TRANSCRIPT

0:02

hi there my name is michael moore

0:05

founder of wm development and my goal is

0:08

to make you the best game developer and

0:11

the most fun way possible the course

0:14

you're about to watch right now is a

0:15

course that i have on udemy and

0:18

skillshare that has hundreds of super

0:20

positive reviews and today i'm going to

0:23

give it to you for free well not all of

0:25

it because i still have to pay my rent

0:28

somehow give me rent you'll get your

0:30

rent when you fix this anyway you can

0:32

support me by leaving a comment and

0:35

hitting the like button somewhere down

0:37

here and if you got to the end of the

0:39

course or you are somewhere in the

0:42

middle and you want to get the full 10

0:44

hour version

0:46

just scroll down to the description and

0:48

i've left their links with that you can

0:50

use to get either to get it either on

0:53

udemy or skillshare whichever you prefer

0:56

of course with a special coupon to save

0:58

you a bit of money i'll also leave a

1:01

link to the discord server that you can

1:04

use to join

1:05

our great and growing community where

1:07

you can share your game if you have any

1:10

questions you can ask them and you can

1:12

help out by answering some questions

1:14

there also finally if for some reason

1:17

the links in the descriptions don't work

1:20

you can contact me either on discord or

1:22

on instagram or on linkedin and i'll

1:26

help you out now let me give you a quick

1:29

guide on how to watch the course and how

1:31

to navigate through the long video so if

1:34

you're a total beginner i recommend that

1:37

you start off at the very beginning from

1:39

the first course where we start with the

1:42

very basic introduction and downloading

1:44

unity and all of that good stuff and if

1:47

you want to refresh your memory a bit

1:49

you already know your way around a bit i

1:52

recommend that you start at this time it

1:54

will be somewhere around me and you can

1:56

start from that video or that time stamp

1:59

it will immediately take you

2:01

you will not have to go through the

2:03

downloading and all the small processes

2:05

you will just start up where the course

2:07

begins and if you are already a seasoned

2:10

unity user and you just want to see how

2:12

this course is made and what you can do

2:14

then i'll also leave a timestamp

2:16

somewhere around here that you can use

2:18

and just get into the neck of it the

2:21

video will be timestamp so in here down

2:24

below on the bar red bar everything

2:26

should be timestamped if not i will

2:28

leave the timestamp in the description

2:31

so you can go to any video that you like

2:33

i also use sourcetree which is a very

2:36

powerful tool

2:38

so i recommend that you watch the video

2:40

or the little section which should be

2:42

around here on on the source tree it's

2:44

like maybe a 16 minute video it's not

2:47

necessary to complete the course but

2:49

it's a very powerful tool and i do

2:51

recommend that you check it also i

2:54

recommend that you watch the how to use

2:57

this course which will give you the

2:58

basic ideas because i have challenges

3:01

and stuff anyways good luck and remember

3:04

to have

3:05

fun

3:07

[Music]

3:12

welcome back everyone so in this video

3:15

we are simply going to be downloading

3:18

unity hub

3:19

installing our

3:21

version of unity and setting up

3:23

everything in order to start creating

3:26

games

3:27

so

3:28

let's get started first thing you need

3:30

to do is you need to go into whatever

3:33

browser you're using i'm currently using

3:35

google chrome it doesn't matter

3:37

simply go ahead to google and type in

3:40

download unity hub and you should get

3:43

this search result so simply go and

3:46

click on the download unity hub it

3:48

should be the first link which should be

3:50

on the unity3d.com

3:53

website and it will take you to this

3:56

page right here and it will ask you to

3:59

download unity hub now what is unity hub

4:02

well unity hub is a place

4:05

where we can add different versions of

4:07

unity

4:08

and we can also

4:10

have all of our of all all of our

4:13

project represented very neatly and very

4:16

carefully which is very helpful and much

4:20

better than as the way we used unity

4:23

before that

4:25

so simply click on download unity hub

4:28

and you should get the installation

4:31

which is right here which is unity hub

4:34

setup so double click on that and it

4:37

will start an installation it's fairly

4:40

easy you simply click on agree and

4:42

install it in whatever destination

4:45

folder that you have i already have

4:47

unity hub so i won't bore you with the

4:50

download process it will ask you to

4:52

agree to something which is fairly easy

4:55

so go ahead and install unity hub

4:58

okay so now that you have unity hub

5:01

installed you should you should

5:03

get this window right here and first

5:06

thing you'll need to do because i'm

5:08

already signed in so you need to create

5:11

an account i'm currently using my

5:16

google email which is very helpful and

5:19

much easier

5:20

and here you can see that we have all of

5:23

our projects now currently we don't have

5:25

any projects yet but we will very soon

5:29

here you have different tabs for

5:31

learning and for the community which you

5:34

can go and check out and see what there

5:36

is but what we're going to focus on

5:38

right now is going into installs now as

5:41

you can see i already have a version of

5:44

unity which is

5:46

2020.1.2 f

5:48

1.

5:49

so

5:50

maybe you're from the future and you

5:52

have a better version or a more

5:55

uh or a newer version and in order to

5:58

add a new version you simply click right

6:01

here on the app so when you click on add

6:03

it gives you a different options to

6:06

download unity now as you can see you

6:08

have recommended releases you have

6:11

official releases and you have pre

6:14

releases now what should you choose

6:17

well personally me i like to choose the

6:20

official releases because

6:22

they are usually the least buggy there

6:25

is the recommended release which is also

6:28

not bad and there are the prerelease

6:30

pre-releases and now pre-releases are

6:34

not always that buggy but sometimes you

6:36

may encounter um

6:38

not very good performances during play

6:42

or during

6:43

game creation

6:44

they are not that common but i

6:46

personally prefer the official releases

6:49

so go ahead and choose one of them let's

6:51

choose the official release of

6:53

2020.1.10f

6:55

and let's click on next now this should

6:58

take you to another

7:00

modules to your installation window and

7:04

what we have here

7:05

is bunch of add-ons and

7:08

uses

7:09

for the

7:11

unity so for example you have android

7:13

build which will help you build games

7:16

for android you have linux build support

7:19

and mac and so on and so forth you also

7:22

have the documentation which i recommend

7:24

you download and you have the language

7:27

pack which if you have some kind of

7:30

different language chinese or korean i'm

7:32

not sure what those are you can also

7:34

check one of them and download that but

7:37

most importantly is you have to check

7:40

this developer tool which is microsoft

7:42

visual studio community 2019 maybe you

7:45

have a newer version

7:48

so this is absolutely a must because we

7:52

will be using the visual studio to code

7:55

all of our games so go ahead click on

7:59

those and click on next and the download

8:02

should start right here well you have a

8:04

box similar to this one and with a

8:07

little blue bar up here waiting to

8:10

finish the download so

8:12

now i'm going to introduce you to your

8:14

challenge and this is your challenge for

8:18

today so you need to download unity and

8:21

visual studio so first of all go ahead

8:23

and download unity hub then download

8:27

unity's latest release

8:29

and make sure you also download visual

8:32

studio with

8:34

unity so go ahead and do the challenge

8:38

and i'll see you in the next video

8:41

[Music]

8:46

welcome back my favorite game developers

8:49

i've created this video in order to help

8:52

you maximize

8:54

your learning potential in this course

8:57

so let's talk about the few things that

9:00

you will need in order to do that

9:03

first thing we have the q a

9:06

and what is the q a well it's a place on

9:10

udemy where you can actually ask me any

9:13

question that you stumble upon so if you

9:16

find yourself

9:17

in a certain video and you're not able

9:21

to complete the task at hand or you're

9:23

finding something very hard and you

9:26

can't understand it you always have the

9:28

q and a right here under each video

9:33

here you can first of all search for

9:36

your question maybe someone has already

9:38

asked the question and he and you can

9:41

find the answer

9:43

right under there

9:45

and if if you don't find the answer you

9:48

can always ask a new question so first

9:51

thing you'll need is the

9:53

question title make sure it's very

9:55

precise and

9:57

to make it easier on me and maybe other

10:00

people in the community make sure that

10:02

you always add as much precision and

10:06

make your question as clear as possible

10:09

so add code to it some people might use

10:12

this code and and to try it out in their

10:15

own game and see what's wrong you can

10:17

add images of certain errors and make

10:20

sure that you for example maybe make the

10:23

important words italic make sure that

10:26

your question is as concise and precise

10:29

as possible

10:31

and finally

10:33

if you do find or you can always go back

10:36

and lead the question if you find the

10:37

answer or you can edit and if you do

10:41

edit your question make sure to add

10:43

these solved

10:46

in the title so if you find that your

10:49

question has been solved and and has

10:51

been answered satisfactorily

10:54

make sure that you add in the question

10:57

titled these

10:58

words right here solved and this will

11:00

not only help me to know which questions

11:03

still haven't been solved it will also

11:06

help other game developers just like you

11:10

find the answers to their questions and

11:13

find them solved in the q and a

11:16

great

11:17

next thing let's talk about the

11:19

challenge slides so you've already

11:21

encountered your first challenge slide

11:24

and this is your challenges slide so

11:27

whenever you see this slide you need to

11:29

pause the video and do the challenge on

11:32

it it's a much better way to learn and

11:36

doing

11:37

is always better than watching in my

11:40

book so whenever you see the challenge

11:42

screen know that it's a great

11:45

opportunity to go out and try to tackle

11:47

the task at hand and the reason i

11:50

created these challenges is for you to

11:52

get as much benefit from the course as

11:55

you possibly can

11:57

i've personally tried over 10 courses

12:00

where the instructor simply goes through

12:03

the motions and at the end of the course

12:05

i had created a game with the instructor

12:08

but i haven't learned anything and i

12:11

felt i would never be able to replicate

12:14

any of it the challenges give you the

12:17

opportunity to try make a mistake and

12:20

get stuck trying to solve the problem

12:22

and even if you can't figure it out if

12:25

you have no idea how to do the challenge

12:28

try even even if you cannot complete the

12:31

challenge when i complete the challenge

12:34

after you've tried it will be in

12:37

ingrained in your brain and next time

12:39

you see the problem you'll remember the

12:42

mistakes you made and how not to do them

12:44

again trust me this is the best way to

12:48

learn and will keep you active as we

12:50

work through the game together so next

12:54

thing i want to talk about is the course

12:57

structure so the first section which we

13:00

are currently on will be the

13:02

introduction and the setup where i will

13:05

introduce you to unity if you're new to

13:07

it and introduce you to

13:09

the visual studio and why we'll use it

13:12

we'll actually also create our first

13:15

code and our first script which is very

13:18

exciting

13:19

the second

13:20

section will be the magic game cube okay

13:24

so and it's a cube that is in 2d which

13:27

makes it magic

13:29

and it basically will cover the c sharp

13:32

and unity basics we'll talk about the

13:34

basics of c sharp and the tools that

13:36

we'll need for our coding later on and

13:39

the basics of unity and everything that

13:42

we need to understand

13:44

from collisions to rigid bodies to

13:47

physics in unity and so on and so forth

13:50

now the third sex section is where

13:53

things will get very interesting and

13:56

it's our project which is castle

13:58

conquest to d and in this in the section

14:02

three we're going to be setting up our

14:04

world we're going to be creating our

14:07

tile sets we're going to be creating our

14:10

world adding collisions to that world

14:12

and adding our player

14:14

but not so fast because in section 4

14:18

we're going to be adding our conqueror

14:21

and we may have we may introduce our

14:24

conqueror in the section 3 but in

14:26

section 4 we're actually going to give

14:29

him the abilities to jump to run to have

14:33

different animation and so on and so

14:36

forth now in section 5 is where things

14:39

get a bit scary because we're adding

14:42

enemies and bombs so now our player is

14:45

no longer safe he will have to

14:48

fight off enemies and he will have to

14:50

avoid bombs along the way as he tries to

14:53

conquer the castle

14:56

and in section six we'll uh start

14:59

controlling our game so we'll be adding

15:01

a score we'll be adding lives we'll be

15:04

adding multiple levels to our game and

15:08

everything that goes on with it will

15:09

actually also be adding a lot of sound

15:12

effects and make our game much cooler

15:14

and finally in section seven we'll have

15:17

the bonus section and i've created this

15:19

section

15:21

i actually added this section on because

15:25

all the core game mechanics will be in

15:27

the

15:28

first uh fourth section but the seventh

15:31

the last section or the bonus section

15:34

will be where we tweak things a bit and

15:37

just

15:38

for the fun of it make our game a bit

15:40

more exciting and more fun so

15:44

make sure to always check out the

15:46

resources that are next to each video if

15:49

you find them there i will be linking

15:51

the

15:52

documentations to unity i will be

15:55

linking changes to our code and the

15:58

different things that may help you in

16:00

the current video and finally as a final

16:04

note

16:05

i just want to say that if you put the

16:08

extra effort into this course you will

16:10

get out of it much more than you paid

16:14

and that really is my goal is to leave

16:16

you as an expert problem solver and a

16:19

good game developer with lots of tricks

16:22

up their sleeves and

16:24

maybe even become a friend so i'll see

16:27

you in the next video

16:30

[Music]

16:36

so welcome back to another video

16:40

let's see what is unity so unity is a

16:44

cross-platform game engine developed

16:47

developed by unity technologies we use

16:50

unity to develop our game so what does

16:54

cross platform means it means that we

16:56

can use it on different platforms and

17:00

it's a game engine and what game engine

17:02

is it's a environment for us to develop

17:06

games and add physics and add different

17:09

things to create our game so let's check

17:13

out what unity actually looks like and

17:15

i'll explain a couple of things on it so

17:19

this is unity first of all we have this

17:22

toolbar right here

17:25

up above everything and this provides

17:28

access to the most essential working

17:31

features on the left we

17:34

it contains the basic tools for

17:36

manipulating the scene view and the game

17:38

object within it

17:39

in the center we have the play the pause

17:43

and the step control button and the

17:45

buttons on the right give you access to

17:47

the unity collaborate unity cloud

17:50

service and unity account

17:52

and will not get in much into that on

17:55

the right side of those we have the

17:59

layer visibility unit

18:01

menu

18:02

and we have the editor which provides

18:05

some alternative layouts for the editor

18:07

window and allows you to save your own

18:09

custom layouts so if you don't have the

18:12

same layout as i do you can simply click

18:14

right here on layout and you can choose

18:16

the default layout and this is the

18:19

default player that we have

18:21

it's the projects right here and

18:23

inspector and everything next thing

18:25

we'll talk about the hierarchy window

18:28

right here it's a hierarchical text

18:31

representation of every game object in

18:35

our scene so each item in the scene has

18:37

an entry in the hierarchy so the two

18:40

windows are inherently linked the next

18:43

hierarchy reveals the structure of how

18:47

game objects attach to each other so

18:49

right here we have the sample scene

18:52

and if we click on that we have the main

18:54

camera under it and if we add another

18:57

game object it will also show up right

19:00

here

19:01

and here is the inspector as you can see

19:04

on the right this is the window

19:06

inspector and it gives it allows you to

19:09

view and edit all the properties of the

19:11

currently selected game object so if we

19:14

don't select the game object we don't

19:16

see anything when we click on main

19:18

camera we have these different windows

19:21

right here and the layouts and content

19:24

contents of the inspector window change

19:27

each time you select a different game

19:29

object so now we don't have a different

19:31

game object so we'll just settle for the

19:34

camera

19:35

next then we have is this scene view

19:39

right here and the scene view allows you

19:41

to visualize and navigate and edit your

19:44

scene the scene view can show you either

19:47

a 3d perspective or a 2d perspective

19:50

depending on the type of project that

19:52

you are using so in scores we'll be

19:55

using the 2d project

19:58

view but you can also right here click

20:00

on the 2d button and it will go 3d

20:04

so as you can see we have this 3d view

20:07

but we won't be needing it we'll simply

20:09

go into the 2d

20:11

mode

20:12

and finally i want to talk about the

20:14

project window right here which displays

20:16

your library and assets that are

20:19

available to use in your project so when

20:21

you import assets

20:24

into your project they will appear right

20:26

here so for example for now we don't

20:28

have any assets we only have the scenes

20:31

folder and inside the scenes folder we

20:34

have this sample folder so this is a

20:37

quick overview of unity and what all

20:40

those panels and gadgets are we will of

20:44

course delve deeper into them as we go

20:47

through the course but now i want to

20:49

talk about

20:51

the something very important and that is

20:54

the visual studio so what is visual

20:58

studio well visual studio is a microsoft

21:02

visual studio

21:03

it's used well it's developed by

21:05

microsoft and it's an ide and ide is an

21:09

integrated development environment and

21:13

what it does it actually if we ask

21:16

meaning visual studio will help us write

21:18

the code used to manipulate game objects

21:21

in the unity

21:24

using something called scripts so how to

21:27

use unity with visual studio so we need

21:31

a way for unity and visual studio to

21:34

communicate but they do not simply do

21:37

that

21:37

we need to add something to it called

21:40

the dot cs file and that is our scripts

21:45

and those scripts allow we actually take

21:48

those scripts we attach them to game

21:50

objects and using those scripts we'll be

21:54

able to add behavior to different kinds

21:57

of game objects and we'll see that very

22:00

very soon so let's go into visual studio

22:04

and see what it's all about this is

22:07

visual studio and maybe the first time

22:09

you open it up you'll have different

22:11

panels right here on the right and

22:14

different windows right here on the left

22:16

feel free to close all of them

22:19

and don't worry about what happens next

22:22

of course you won't have this the first

22:24

time you start up visual studio but

22:26

you'll see it soon enough and i'll just

22:29

introduce you to a couple of line of

22:31

codes right here so let's zoom in just a

22:34

bit

22:35

and right here on the top you can see

22:37

that we are using system collections we

22:39

are using system collection collections

22:42

generic and most importantly we are

22:45

using unity engine now what are all of

22:48

those well those are called name spaces

22:51

and

22:52

basically these are libraries that give

22:56

us the opportunity to use

22:59

different kinds of code so for example

23:02

unity engine which we've added right

23:04

here allows us to use the start method

23:07

and the update method and different

23:10

engines

23:11

to create games and make it much easier

23:14

and we simply right here using unity

23:17

engine and it saves us a lot of code and

23:21

gives us the entire library to use

23:25

next thing we have the public class

23:27

class name and this is the actually the

23:31

class name which should be right here it

23:34

will be the script that we've talked

23:36

about and it will be attached to a game

23:39

object

23:40

and it will encompass all of the code

23:42

that will change the behavior of our

23:45

game object inside of our game and mono

23:48

behavior is a base class and it's

23:52

actually these two mean that it inherits

23:54

from the mono behavior which allows it

23:57

to use uh different kinds of

24:00

manipulations and engine and physics and

24:03

so on and so forth

24:05

and next thing we have is the start and

24:08

of above it is something called the

24:10

comment so whenever you write code and

24:12

add these two

24:14

lines right here it will comment things

24:17

out and comments actually don't get

24:19

executed in the gold the code

24:22

code the code and they are perfectly

24:24

saved so it start start is called before

24:28

the first frame update so as soon as our

24:31

game starts

24:33

the start method and this is called a

24:36

method will start to execute next thing

24:39

we have the update and the update is

24:42

called once per frame

24:44

so

24:45

every frame that we have in our game the

24:48

update is called so start is typically

24:51

used to

24:53

give the initial

24:55

properties or configurations to certain

24:58

objects and the update is used

25:02

for

25:03

objects that maybe are moving or change

25:07

every frame so if we have a car for

25:09

example and start we can give it the

25:12

color the name the speed at which it can

25:16

go and an update will be moving the car

25:19

will be making the car jump will be

25:22

making the car

25:24

go faster maybe increase its speed so

25:27

you get the basic idea of visual studio

25:31

and now it's time for your challenge and

25:34

your challenges to go make a mess so

25:38

open unity create a project and if you

25:42

don't know how to create a project

25:44

we'll do that in the next video

25:47

and when you're finished after you go

25:49

make a mess go to the next video and

25:51

we'll make our first code and get

25:54

started so i'll see you in the next

25:57

video

26:03

[Music]

26:08

welcome back my fellow game developers

26:12

in this video we are going to be

26:14

creating our first code and our first

26:18

game object so as you can see right here

26:21

we have a game object called hello world

26:24

in anaha in our hierarchy it's present

26:27

right here in our scene although we

26:29

don't see it very well and we have this

26:32

script right here attached to it we've

26:35

also created the script right here in

26:36

our project

26:38

and in console if we click on play

26:43

we actually get a message that displays

26:45

hello michelle which is me but in your

26:48

case it will it's going to be displaying

26:51

your name

26:52

so i'm very excited for this video

26:54

because it's our first

26:56

delve into unity world so i hope you

26:59

enjoyed the video and i'll see you in

27:01

just a bit

27:03

okay so first thing we're going to do is

27:06

we're going to open up unity hub and

27:09

currently you have no projects here

27:12

which will change in just a bit first

27:15

thing we'll do is click on new right

27:17

here

27:18

and we'll need to choose a template for

27:21

our game so we'll be creating a 2d game

27:24

not a 3d and these are different options

27:27

also

27:29

for different project types next thing

27:32

we'll need to add a project name feel

27:34

free to name it whatever you want we'll

27:36

be calling it for now the hello world

27:38

the project

27:40

and make sure that you choose a location

27:43

for your unity

27:46

project so we'll click on this one

27:48

and let's go back and save it inside of

27:51

the unity projects so select the folder

27:55

and now we have a location for our game

27:59

you need to do all you need to do right

28:01

now is click on create so click on

28:04

create

28:05

and unity will start to create your

28:08

project and i will not bore you with the

28:11

uh

28:12

waiting here i'll use the magic of

28:15

editing and we'll simply jump into the

28:18

project so see you in a bit

28:20

welcome back so i hope your project also

28:25

finished setting up so this is our scene

28:28

if you don't have this kind of scene as

28:31

i've told you you can always go to

28:33

layout and choose the default layout and

28:36

we'll have the same layout both of us

28:39

so before we start let's

28:42

first of all add something called the

28:44

console and as you can see even before

28:47

we start anything we have this console

28:49

window right here and what this does is

28:52

it shows us the messages and we're going

28:55

to use this console window to see the

28:57

things that will print from our code and

29:00

if you don't have it you can simply go

29:02

up here in window click on it

29:05

and just above here you can see on the

29:08

general

29:09

we'll have the console so click on it a

29:12

window should a appear and you can dock

29:15

it wherever you want i'm going to dock

29:17

it right here next to projects another

29:21

thing i want to talk about is in the

29:24

wherever you've saved your uh project

29:27

i've saved it in d unity projects and

29:30

hello world so as you can see we have

29:33

different folders right here we have the

29:35

assets which hold our scenes and

29:37

everything that we create in projects

29:40

you can see the assets and project

29:42

assets right here

29:44

we also have the library which

29:47

automatically

29:49

is created every time we enter a project

29:52

we have logs we have packages we have

29:55

project settings all our though all of

29:57

those are details that will not get into

29:59

too much and the temporary folder which

30:02

we'll

30:03

discuss later on in the magic cube to

30:06

the

30:07

game so let's go back into unity and in

30:10

here we are going to be creating our

30:13

script so let's right click in here

30:16

and let's go into create and in create

30:20

we can actually create multiple things

30:22

as you can see we'll do a couple of them

30:25

in our project but for now let's simply

30:27

create a c-sharp script so click on that

30:32

and before you do anything so

30:34

now don't do anything

30:36

leave everything

30:38

you will need to make sure that whenever

30:40

you name a script that you do it with

30:43

precision because it will cause error

30:47

later on if you want to try to rename

30:50

your script so make sure you name it

30:52

correctly from the get go so we'll name

30:55

this

30:56

hello

30:57

world without any spaces and click on

31:00

enter when you're sure that you have

31:03

decided on the name of the script so

31:06

click on enter and i'll tell you why in

31:08

just a bit so as you can see

31:11

we have something right here in the

31:12

inspector and it took a bit of time and

31:15

it's because unity needs to compile the

31:19

code right here and you can actually see

31:21

the code in the inspector and why i told

31:24

you it's so crucial to make sure that

31:27

the name of the

31:28

script right here is

31:31

defined before we click on enter it's b

31:33

is because

31:35

it is going to be the name of our class

31:38

so if you change the name of our script

31:40

right here the class name won't change

31:43

and there will be an error where unit or

31:46

the visual studio will not be able to

31:49

find the correct script in the project

31:52

and this will cause errors so to avoid

31:54

that simply make sure that you name your

31:56

script correctly and precisely from the

31:59

get go now what should we do next it's

32:03

very simple you simply double click on

32:05

hello world

32:07

and the visual studio should open up

32:11

and as you can see right here this is

32:13

what we've described a couple of

32:17

maybe in the previous video

32:20

so what are we going to do in here we

32:23

are simply going to print something to

32:25

our console and we'll do that inside of

32:28

start so let's go ahead and print

32:32

so as you can see immediately visual

32:34

studio our great friend starts to help

32:37

us and it gives us suggestion for what

32:40

we want to use so we

32:42

write the print it gives us the

32:44

suggestion and now you can simply click

32:47

on tab and it will finish it for you

32:50

and now we open up our brackets and we

32:53

can see that visual studio again helps

32:56

us and it tells us that we need to add a

32:58

object message inside of here and that

33:01

object message is going to be a string

33:04

we'll talk about strings later but for

33:06

now string is a

33:08

string of characters that we put inside

33:11

of these two quotes right here so let's

33:13

go ahead and add these two quotes again

33:16

and now we write inside of these two

33:18

quotes hello

33:20

world so

33:22

is that enough well actually no because

33:25

if you see right here we have this

33:27

squiggly red line and if we hover over

33:30

it it tells us that it expects

33:33

a

33:34

symbol which is this one and every line

33:38

of code in c sharp you have to add this

33:41

semicolon right here so save that

33:46

and now because we've put it inside of

33:48

start as soon as we start our game this

33:52

message should be printed on the console

33:55

so let's try that we go back into unity

33:59

and we go into console but if we click

34:02

on play

34:05

as you can see nothing is being

34:07

displayed on our screen

34:09

why is that because it's not enough just

34:13

to create a script you actually need to

34:15

attach it to an object so let's create

34:18

an object and the way we do that we

34:21

simply go into our hierarchy we right

34:24

click on here

34:25

and we can create a empty game object

34:29

click on that and now we have a game

34:31

object let's go ahead we can change the

34:34

name of that game object we'll call it

34:36

um

34:38

let's call it

34:39

hello

34:41

world

34:42

object

34:44

click on enter and below it you can see

34:46

that it's we have the transform and this

34:49

transform tells us the position of our

34:51

game object in the world

34:53

and up here we have the tools to

34:55

manipulate so if you click on this tool

34:58

you can actually put the object up or

35:00

drag the object down

35:02

take it to the left or to the right and

35:05

put it anywhere we want

35:08

and currently we cannot see we don't

35:10

have anything to represent our game

35:12

object we simply have its coordinates

35:15

and its transform so let's attach the

35:18

script to this game object to do that we

35:20

simply click on the

35:23

script and drag it into the hierarchy

35:25

into the hello world

35:28

object so if you click on hello world

35:30

object right here you can see that it

35:32

has a script

35:33

just below the transform attached to it

35:36

and now if we click on play

35:41

in the console we can see that we have

35:43

hello world

35:45

congratulations you've just written your

35:47

first code and you've just used your

35:49

first game object to display something

35:52

to the console great and now it's time

35:57

for your challenge and your challenge is

36:00

going to print your own name so instead

36:04

of hello world you'll need to print your

36:07

own name

36:08

so change hello world to hello

36:11

and and

36:12

instead of those three dots of course

36:14

it's going to be your own name

36:16

i'll give you a couple of hints so add

36:19

your name inside of the dots

36:22

save visual studio always remember to

36:24

save visual studio using ctrl s

36:27

go to unity and click on play

36:31

and check your console so

36:34

make sure it works

36:37

pause the video right now and go do the

36:40

challenge

36:42

okay welcome back how did you get around

36:45

with that i hope you tried your best in

36:48

that challenge

36:49

let's go into visual studio and instead

36:52

of world i'm going to delete that and

36:55

i'll put my own name which is

36:58

michel so hello michelle

37:00

and we'll just add an exclamation or

37:03

three exclamation points for the

37:05

dramatic effect

37:06

and to make sure that you've saved your

37:08

project i mean your script when you look

37:11

up right here you can see that it has a

37:14

small asterisk attack asterisk astrix

37:17

attached to it and to save that you

37:20

click on and that means it hasn't been

37:22

saved so if you hold ctrl s click on

37:26

control s you can see that the asterisk

37:28

asterix disappears and that means that

37:31

the script has been saved go back into

37:34

unity

37:35

you can see that there is an asterisk

37:38

right here also next to the sample scene

37:40

so save that

37:42

and now if we go to console you can see

37:45

right here that we have this button

37:46

clear or you if you click down you can

37:49

see that we can click on play you can

37:52

remove that feel free it doesn't matter

37:54

we'll just remove it to see the changes

37:57

that happen and now if we click on play

38:02

we will have hello michelle

38:04

or hello whatever your name is my fellow

38:07

student and

38:10

that is all so clear that let's try that

38:13

again click on play

38:15

and hello michelle hello my favorite

38:19

game developers i hope you enjoyed the

38:21

video and i'll see you in the next one

38:30

[Music]

38:36

welcome back my fellow game developers

38:38

in this video we are going to be

38:40

learning everything about

38:42

version control source tree

38:45

and creating repositories of our

38:48

projects so as you can see right here

38:50

we've created a new project we started

38:53

our big project which is cyberspy 2087

38:57

and we've downloaded sourcetree we now

39:00

have a couple of comments in here and we

39:02

actually reverted something we've

39:04

created our initial commit added a cube

39:07

reverted it we can actually reverse this

39:10

commit again so click on yes as you can

39:13

see we can go back to unity reload and

39:16

we have our cube right here we will be

39:20

learning everything in my new detail so

39:23

give me your entire concentration this

39:25

is very important it's an extremely

39:28

helpful

39:29

video or lesson and will stay with you

39:32

forever as long as you are committed to

39:34

becoming a professional

39:36

programmer or game developer so let's

39:39

not waste any more time and let's get

39:42

started

39:44

okay so version control

39:47

let me put on my laser version control

39:50

it's hard to learn it's even harder to

39:53

teach but i'll try to keep it as simple

39:55

as possible and when you get the hang of

39:58

it trust me it's very simple and easy to

40:01

use plus it's an indispensable skill

40:05

that you need to learn if you are

40:07

looking to become a professional

40:09

game developer or even a professional

40:12

programmer so let's get started with

40:15

what is it

40:16

first of all it's a system that is

40:18

responsible for managing changes to

40:21

computer programs so this means that

40:24

whenever we create changes in our

40:26

programs we can actually save those

40:29

changes at each step of our project this

40:33

way we can first of all check what we

40:36

did we can create different kinds of

40:39

versions where we can go back and change

40:42

the things that we've created it allows

40:44

for a better

40:46

teamwork so for example let's say you

40:48

have four or five people working on the

40:51

same project but each one of them has a

40:54

different task that they need to create

40:56

so version control is a very good

40:59

way of handling all of this and why do

41:02

we need it well

41:04

why we we actually use it well we'll use

41:07

it to remember previous version of our

41:09

game and have more flexibility to

41:12

experiment

41:13

usually game development is

41:16

a

41:16

environment where you require a lot of

41:19

experimentations for example you want to

41:22

add

41:22

some kind of

41:24

property to some kind of game object and

41:27

maybe it breaks your entire project so

41:29

you want to always have a previous

41:32

version of your project before adding

41:34

this game breaking mechanic so you can

41:37

always go back and start fresh from

41:40

there so this is extremely important

41:43

especially for game developers that

41:45

always need to be experimenting with new

41:48

ideas and things in their games and

41:51

projects

41:52

and how are we going to use it well we

41:54

are going to be using something called

41:56

sourcetree and this is version control

41:59

it allows us to create different

42:01

versions and it's first of all it's for

42:04

free it's very easy for beginners

42:07

very flexible and it has a very simple

42:11

interface that we can use as beginners

42:14

so let's go ahead and download

42:16

sourcetree let me show you where we can

42:18

do that

42:19

if you open up

42:21

google

42:22

chrome or any browser that you have

42:24

simply go to google and write in here

42:26

download source tree you should find a

42:29

link right here and it should be the

42:32

source tree app when you click on it you

42:35

go right here to their website if you

42:37

scroll up you can see that you have the

42:40

option to download for windows but if

42:43

you are on a mac make sure that you

42:45

click on here and you download source 3

42:48

for mac os or it will not work for you

42:52

so if you have a mac download the mac

42:54

version if you have

42:56

a windows download the windows version

43:00

simple enough now when you finish

43:02

downloading you should get this file

43:04

right here and when you double click on

43:07

it you should start the installation now

43:09

because i already have source 3 i will

43:12

not be installing it another time i will

43:14

just take you through the process of

43:17

actually installing it ok so this is the

43:20

first window that will pop up for you

43:23

first of all you need to agree to the

43:25

license of course and you can maybe turn

43:28

this off if you don't want any emails

43:30

your way from

43:32

sourcetree and etc atlasia

43:35

next thing you need to do is you need to

43:38

create an account on atlasian you can go

43:40

to atlasian and atlasian is the parent

43:43

company of sourcetree you can go ahead

43:45

and create an account there or you can

43:47

use an existing account if you already

43:49

have a gmail i personally created one

43:52

using gmail it's much faster it's way

43:55

easier and they don't spam you with a

43:57

lot of emails

44:00

next thing in here we are going to

44:03

connect it to an account now this is of

44:05

course

44:06

we will not be doing this this is if you

44:08

want to host your code on a certain

44:11

website like github or bitbucket we will

44:14

not be doing that so you can simply

44:16

click here on skip setup

44:20

finally while installing sourcetree will

44:22

tell you that it is unable to locate git

44:26

so in order to complete this simply

44:28

click on download an embedded version of

44:31

git

44:32

and continue on

44:34

and then it may also ask you for

44:36

something called a mercurial now

44:39

mercurial is a different system just

44:42

like git it allows us to

44:44

save different versions of our project

44:47

we will not be using mercurial so you

44:49

can simply click on i don't want to

44:52

download or i don't want to use

44:54

mercurial and this should be it

44:57

when you finish installing you should

44:59

have this right here

45:02

and your well this window right here

45:04

when you start sourcetree if you don't

45:07

simply click right here on create and

45:09

you should get

45:11

this

45:12

window now this is where we actually

45:14

create our repository and in here you

45:17

can see that we have the destination

45:19

path the name and the type of version

45:22

control that we want to use of course

45:24

we'll be using the git we also have the

45:26

option to create an account but as i've

45:29

told you we're keeping things very

45:30

simple it's our first time so we will

45:33

not be creating any account

45:36

so in here we are going to choose

45:38

which what is the destination path of

45:41

our repository so what what is the

45:44

project that we are actually going to be

45:47

creating a repository for and subsequent

45:51

versions of

45:53

well let's create our first project that

45:55

we are going to be using

45:58

so in here let's open up the unity

46:02

hub and as you can see we already have

46:04

hello world that we've done in a

46:06

previous video let's click on new

46:09

and let's make sure it's a 3d

46:11

project and this is going to be our

46:14

cyber

46:15

spy

46:16

2087.

46:18

let's go ahead and create this project

46:21

so click on create

46:23

and i of course always using my magic of

46:27

editing in order to speed up this

46:29

process i'll see you on the other side

46:34

okay welcome back so i hope everything

46:37

worked out for you so now we have a new

46:40

project which is cyber spy

46:43

2087 so now that we have our project

46:46

created we can actually go ahead and get

46:48

started with creating a repository now

46:53

if we go back into our source tree right

46:56

here we can click on browse

46:59

and we can actually go ahead into unity

47:01

projects and you can see that and we

47:04

have a hello world and we have a cyber

47:06

spy

47:08

2087. so let's select this folder it

47:12

will create a repository under this name

47:14

and if we hit create

47:16

it will ask a problem don't worry about

47:18

it click on yes

47:20

and voila now we have actually started

47:24

creating a repository you have the

47:26

staged files right here you have

47:29

different kind of knobs you don't need

47:31

to worry about any of them for now just

47:34

focus on the staged files unstaged files

47:37

and commit up here now if we scroll down

47:41

in these unstaged files you can see that

47:43

most of them are from the library

47:46

we scroll down to the end we can see

47:48

some of them are tamper temp

47:50

or temporary we can see also that we

47:53

have project settings and these are all

47:55

the files that we have

47:57

for our project we also have assets in

48:00

here for unity in the scenes for example

48:03

so this is a repository which is a

48:06

version of our current project

48:10

now

48:11

the problem here is as you can see there

48:13

are a ton and ton of files

48:16

and we will not be needing all of them

48:19

well actually we'll need

48:21

almost none of them we will need only a

48:24

certain kind of files

48:26

so we want to be ignoring the library

48:29

and the temporary temporary files why is

48:32

that well let me show you by opening up

48:35

the

48:36

directory of our current project

48:45

okay so this is cyber spy 2087's

48:49

directory inside of unity project as you

48:52

can see up here so we have the assets

48:54

the library logs packages etc and etc

48:58

now what is the temporary folder and

49:01

what is the library folder and why don't

49:04

we actually need them so temporary is

49:07

just a way for unity to open up faster

49:10

whenever we start the project and it's

49:13

always created whenever we open a

49:15

project so for example if i go into

49:17

unity right here and i actually close it

49:21

you'll see that the temporary file

49:24

will disappear and even if we delete the

49:27

library right now so let's go ahead and

49:29

delete this library entirely

49:31

if we go back into our unity hub and

49:34

open up cyberspy 2087

49:38

as you can see right here you saw that

49:40

the library has been created again and

49:42

the temporary folder has also been

49:44

created so of course the project should

49:47

take a bit more time now to open up but

49:51

this is evidence that a library and the

49:53

temporary folders are not necessary for

49:56

us to always commit and stage

50:00

and what do i mean by stage so whenever

50:03

we stage our folders

50:05

we actually create a commit from them

50:07

and a version of them and library takes

50:11

up a lot of space as you can see if we

50:13

scroll down it takes up most of the

50:15

space and we don't want any of them at

50:19

all

50:20

so

50:21

how should we proceed well we can

50:23

actually ignore all of the folders that

50:26

are under the library by simply going

50:29

and choosing any of the folders that

50:31

have library on them

50:33

right click on it

50:34

and in here you can see that we have the

50:36

option to ignore one of them so click on

50:39

ignore

50:40

and in here you have the option to

50:43

ignore this exact file name ignore all

50:45

files with this extension or you can

50:48

ignore everything beneath a library and

50:51

this is what we want so click on ok

50:55

and as you can see everything under

50:57

library has now been ignored so we

50:59

cannot stage it so we cannot save it to

51:01

our newer version and if you scroll up

51:04

you might have noticed that we have a

51:06

new folder in here that is the dot git

51:09

ignore and when we click on it on the

51:12

right you can see that it has the

51:14

library in it and if we double click on

51:17

it we can actually open it up in our

51:20

notepad and in here we can add the

51:22

different files that we also want to

51:25

ignore so

51:27

what are the files that we want to

51:29

ignore well there are a ton and ton of

51:32

files but thankfully somebody has

51:35

actually gone through all these files

51:37

and created a list of everything that we

51:40

can ignore whenever creating version

51:42

controls or versions of our project

51:46

and in order to find that file you can

51:48

go again into google our dear friend

51:51

go ahead and search dot get ignore unity

51:54

and you should have this link right here

51:57

for the github.com

52:00

it's it will be hosted on github if you

52:02

open up this link it will take you right

52:05

here so this is the dot git ignore and

52:07

it's the unity dot get ignore and these

52:11

are all the files that we can ignore

52:14

when creating versions of our

52:17

project you can click on raw right here

52:20

and it will open up this window or this

52:23

tab

52:24

let's go ahead and select all of them by

52:26

clicking on control a

52:29

we will copy all of this using ctrl c

52:32

and we are going to paste it in here in

52:36

our dot git ignore notepad

52:39

and now we have this git ignore

52:42

notepad filled with all the files that

52:44

we will not use for our repository we

52:47

will save that using ctrl s

52:50

and now back in unity or i mean back in

52:53

source tree you can see that when we hit

52:55

the get ignore everything is ignored we

52:59

will stage all of that

53:01

and when we stage all of that you can

53:03

see that these are the files that are

53:05

going to be committed and these will be

53:08

our initial commitment or our initial

53:11

repository version of the project and

53:15

usually whenever you create your initial

53:18

commit we call this the initial

53:21

you can capitalize it

53:23

the initial

53:24

oops

53:26

initial

53:27

commit

53:28

and we click on commit right here

53:32

so now if you look on the left you can

53:34

see that we have branches under here and

53:37

we have the

53:38

master branch

53:40

congratulations we have created our

53:42

first commitment

53:44

very nice now

53:46

let me just show you how we will move

53:49

further down the line even though this

53:51

video has been long enough but i think

53:53

we need to

53:54

get a proper

53:56

foundation for sourcetree and version

53:59

control as we move through our project

54:02

so let's say we are in our project right

54:04

here

54:05

and let's go ahead and create some kind

54:08

of cubes 3d object

54:10

right click in the hierarchy 3d object

54:13

create a cube and now we have a cube

54:16

let's scale it up a bit so scale it on

54:19

the x the y and the z

54:21

great so now we have a cube in our scene

54:25

and now if we go into sourcetree let's

54:28

save that before we go

54:30

and it needs to save it to a certain

54:32

scene so let's inside of scenes this

54:35

will be our sample scene sure sample

54:37

scene yes replace it so we have this

54:41

sample scene

54:42

back in sourcetree

54:44

wait for it a bit and you can see that

54:46

we have uncommitted changes so if we

54:49

click on them you can see that the

54:51

unstaged files are changes inside of the

54:55

scenes which is the sample scene and

54:58

here you can look in detail what we've

55:00

created now it's a bit

55:02

weird right here but if you look closely

55:04

you can see that we've created box

55:06

collider and basically this represents

55:08

the cube that we've added to our scene

55:12

so let's go ahead and stage all of that

55:15

we can click on comment right here

55:17

and name this added a cube

55:21

click on commit

55:23

and now in our master branch you can see

55:25

that we have an initial commit which

55:27

didn't have any cube and now in our

55:30

added cube we've well added a

55:34

cube so congratulations

55:37

and

55:38

as a final note

55:39

uh this may look a bit cumbersome this

55:42

may look a bit weird but don't be afraid

55:45

this is very simple and more importantly

55:48

it's extremely important for us to

55:51

understand as we move through our

55:55

project create version

55:57

versions of it and if we ever make a

55:59

mistake we can actually go back by right

56:02

clicking in here and reversing the

56:04

commit

56:05

and yes we can reverse the commit if we

56:08

go back into unity it will ask us for a

56:11

reload we wrote we reload and

56:14

now we don't have the cube or any game

56:17

breaking mechanic that we've added along

56:19

the way and now

56:21

it's time for your challenge and your

56:24

challenge is going to be to download and

56:27

set up sourcetree and

56:29

the ignore file so

56:31

download sourcetree install and set up

56:34

everything create your 3d project in

56:36

unity hub set up a repository for it in

56:39

sourcetree ignore the library files get

56:42

the dot ignore file and add it to your

56:45

repository create your first commit and

56:48

then create your second commit you can

56:50

even go ahead and try to maybe play

56:53

around with a couple of things add a

56:54

cube reverse the commit see what happens

56:58

get comfortable with sourcetree and

57:00

if you're having a bit of trouble you

57:02

can pause the video on this list of

57:04

things that you need to create

57:07

and you can also always go back and

57:09

watch the video and see how i made

57:11

everything and follow along with me step

57:13

by step so i'll see you

57:16

in just a bit

57:18

so

57:18

in the next video we are going to be

57:20

setting up our world creating various

57:23

materials and starting our big cyber spy

57:28

2087 project so i'll see you there

57:34

hey

57:35

congratulations you are almost around 20

57:39

to 25

57:40

down the course you know that there are

57:43

very few people that have made it that

57:45

far and you are one of those people

57:47

congratulations i hope you're having fun

57:50

so let's not waste any more time and

57:52

let's continue on with our journey

58:01

[Music]

58:06

welcome back everyone to another amazing

58:09

video in this video we are going to be

58:12

printing things to our console

58:14

but not using print but using debug.log

58:18

which will enable us to add warnings and

58:21

errors and we'll do that using a script

58:24

that we've created

58:26

in our project we'll be adding it to our

58:28

magic cube so as you can see in

58:30

inspector we have this script attached

58:33

to it right now and

58:35

we'll be creating some code very scary

58:39

but not too much and finally we'll be

58:42

committing our project so let's get

58:45

started

58:47

okay so

58:48

first thing you need is this console

58:52

window if you don't see it just yet you

58:55

can simply go into window

58:57

and go into

58:59

our

59:00

where is it so it's in general

59:05

console

59:07

simply click on it and you should get

59:08

this console window it would

59:11

be up here somewhere you can simply dock

59:14

it next to our project okay great

59:18

if you look closely you can see that we

59:20

have click clear collapse so clear what

59:23

it does it is it clears all of our

59:25

console i've checked it on clear upon

59:28

play

59:29

we have collapse which means that when

59:32

we have several messages that are the

59:34

same it simply collect com

59:37

collapses them into a single message and

59:40

here on the right we can see that we

59:42

have

59:43

three buttons that we can check and and

59:46

uncheck one of them is messages

59:49

the middle one is the warnings and on

59:52

the right we have the errors that's the

59:54

scariest messages we can get

59:56

okay great so

59:58

next we're going to create our c-sharp

60:01

script you are already familiar a bit

60:04

with it so go to our project right click

60:08

go to create and click on c-sharp script

60:11

whenever you want to name something like

60:14

this make sure that you

60:16

name it correctly the first time we've

60:18

talked about this so what are we going

60:20

to name it let's simply name this cube

60:24

click on enter now we have our cube

60:26

script excellent

60:28

so we can open this up by doubly

60:30

clicking on it

60:32

and visual studio will compile

60:36

waiting for it

60:38

anytime now

60:40

loading solutions

60:43

and we should have everything in

60:47

okay great

60:49

so as you can see we already have some

60:51

code in here

60:52

we don't we won't be worrying about that

60:55

what we will be doing is we'll go into

60:57

our start method

60:59

and inside we're going to be printing to

61:02

our console now if you went through the

61:05

first section you may realize that we

61:08

used print but now we're going to use

61:11

debug

61:12

and as always visual studio is extremely

61:15

helpful so db debug

61:18

click on tab it will finish it for you

61:20

dot log and open up the brackets and as

61:24

i've said previously we've used print

61:27

but now we're using debug why is that

61:30

well debug gives us more flexibility and

61:32

control and it's technically better and

61:36

it gives us better habits for future

61:38

coding so what is the message we're

61:40

going to write in here the message will

61:43

be

61:45

hello

61:46

everyone

61:47

everyone

61:49

i'm

61:50

printing

61:51

from

61:53

debug

61:55

okay

61:56

put a semicolon there and now

62:00

we save it put a ctrl s

62:02

go back into unity

62:05

but now if we click on play

62:08

we should not see anything and why is

62:11

that we only see our square in the scene

62:13

but nothing is printing to the console

62:16

that's because we haven't attached our

62:18

script to anything so let's go ahead and

62:21

attach it to our magic cube

62:23

save that and now when we click on play

62:27

and go into console we should have hello

62:30

everyone i'm printing to debug

62:33

excellent okay

62:36

now it's time for your challenge

62:40

and you will need to add a couple of

62:42

lines so first thing you'll need to add

62:44

two messages that display on the console

62:47

telling to the player to press a certain

62:50

arrow key

62:52

next you'll need to add one warning

62:54

message

62:56

and finally you'll need to add one error

62:58

log message and i'll i'm going to be a

63:02

bit helpful with you here if we go into

63:05

visual studio

63:07

i will give you a hand so if we click on

63:09

debug if we dot log we can see that we

63:12

have log error and log warning so go

63:15

ahead and get on with that challenge

63:19

welcome back how did you do that it's

63:22

not a very hard challenge but it might

63:24

be tricky if you're just starting off so

63:27

let's create our debug dot

63:31

log

63:32

and

63:33

we'll change this here will tell the

63:36

player

63:38

if you

63:40

press

63:41

the up arrow you'll

63:46

jump

63:47

and below we're right

63:49

if you

63:51

press the

63:53

right arrow

63:55

you'll

63:56

move okay

64:00

and now

64:01

we'll need to create a warning so let's

64:03

go ahead and do that dot log

64:06

warning and simply when you open the

64:09

brackets you can

64:10

click anything if

64:13

you press the

64:16

space

64:20

nothing happens

64:23

and finally our error which will be

64:26

debug.log

64:28

error

64:29

and inside of it what should we write

64:33

if you

64:35

smash the keyboard

64:39

nothing happens

64:42

you just cry

64:45

okay save that

64:47

key keyboard keyboard okay nothing

64:50

happens you just cry save that go back

64:53

into unity everything should be compiled

64:57

and if we click on play

65:00

hello okay great so if you press the up

65:03

arrow you'll jump if you press the right

65:05

arrow your move and we have a warning

65:08

that if you press the space nothing will

65:10

happen and an error if you smash the

65:12

keyboard nothing happens you just cry

65:16

great i hope you enjoyed this oh and one

65:19

last step click on play

65:21

save everything go into source 3 because

65:24

we have uncommitted changes now i don't

65:27

think i'll be doing this every single

65:29

video but you should know that whenever

65:31

we make changes to our game we should

65:34

always

65:36

commit them so stage all

65:38

click on commit here on the far left

65:41

corner

65:42

and what should we call this we'll call

65:45

this

65:47

adding

65:48

a script with

65:51

debug

65:54

debug

65:55

dot log

65:58

inside okay great

66:00

commit that

66:03

and we have it in our master branch and

66:06

i'll see you in the next video

66:09

[Music]

66:14

welcome back everyone to another video

66:18

today we are going to learn about

66:20

variables so we'll learn what variables

66:23

are

66:23

we will learn how we declare those

66:26

variables and we are going to learn

66:29

how these variables make our code more

66:32

flexible so as you can see here we have

66:34

some different kind of messages because

66:36

we've integrated those variables into

66:38

our debug log

66:40

and here in our code we see that we have

66:43

three new variables one is integer the

66:46

second one is a string and we have also

66:49

a float and we've added those

66:52

variables into our debug.log so let's

66:55

not waste any time and let's get started

66:59

so variables what are variables well we

67:03

can

67:04

think of variables like boxes you have a

67:08

box

67:09

that we call lives and we want to put

67:12

some

67:12

information or something inside that box

67:16

to hold it

67:17

so we put a 3 inside of it

67:20

and what is that 3 well it's an integer

67:23

number

67:25

how do we write that in code well we

67:27

have this way of writing it it's an int

67:31

which means an integer lives equals

67:33

three but what do these

67:36

even mean well first of all we have the

67:38

type

67:39

of the variable we have the type here is

67:42

integer

67:44

we have the name of our variable which

67:46

is lives

67:47

and by well it's a common

67:50

tradition in coding if you like

67:53

of naming the variable

67:55

where the first letter will never be be

67:59

capital and all other words inside of

68:02

the

68:03

variable name will be capitalized and

68:06

finally we have the data and the data

68:08

should reflect the type that we give it

68:12

so what other types do we have we have

68:15

float

68:16

variables for example if you want to

68:18

talk about velocity and velocity has can

68:22

be

68:22

4.8 and the way we write it is we

68:26

write float velocity

68:29

and 4.8 f whenever we want to make a

68:32

float variable we add f2 to the end of

68:35

it

68:36

then we have boolean and as you can see

68:39

here we've named it is

68:41

dead where the first

68:43

word of is is not capitalized while the

68:46

second one is capitalized and a bull or

68:49

a boolean can be either true or it can

68:52

be false

68:54

and we also have

68:56

a string variable a string valuable

68:59

means that it has

69:00

it's a string of characters

69:03

or for example here we have the box

69:06

called my name as you can see also the

69:08

second word is capitalized we write

69:11

string my name equals michel which is me

69:15

and we put it inside of a box and now we

69:17

have a variable of string okay great so

69:22

how are we going to translate that into

69:25

our personal code we're gonna make this

69:28

well what actually happens is variables

69:30

make our code more flexible they help us

69:34

manipulate the code in a better way

69:36

let's demonstrate that let's go back

69:40

let's go back into our visual studio and

69:43

let's go ahead and create a variable so

69:46

first thing first if we create a

69:48

variable inside of start right here we

69:51

can only use it inside of start but if

69:55

we write it outside of our start method

69:58

we can use it anywhere we wish in our

70:01

code so let's do that first

70:03

so what variable should we use well

70:06

let's create an integer variable so

70:09

let's say that we have an integer

70:12

we'll name this integer

70:15

number

70:16

of

70:17

times and we'll assign it a value of

70:20

let's say five

70:22

okay

70:23

save that and as you can see

70:26

it's black and white or it's a bit

70:28

transparent that means that we still

70:30

haven't used it and now let's use it

70:33

so if we go ahead in debug.log it says

70:36

if you press the right arrow you'll move

70:40

so let's go ahead and add something to

70:42

it to add a variable we simply do the

70:45

following click on space

70:47

close the bracket or the

70:50

little column in here and then we write

70:53

plus

70:54

we write number and visual studio as

70:57

always this is our best friend and helps

70:59

us

71:00

simply click on tab it finishes

71:02

and we save that and now we have a

71:06

variable inside of our debug let's see

71:09

what happens in

71:11

i mean in unity

71:13

let's go ahead clear all of this and

71:16

click on play

71:18

and as you can see here in our message

71:21

if you press the right arrow five you'll

71:24

move we should have added five times but

71:27

you get the picture

71:28

so now let's add a string variable so

71:32

let's go ahead and click right here

71:34

string

71:36

we'll

71:37

name this

71:38

name

71:39

of the

71:41

key

71:42

and our string will be

71:44

let's say

71:45

space

71:47

so space

71:51

okay so space

71:53

and now we want to add it to the warning

71:55

for example so instead of writing space

71:58

here

71:59

we'll simply

72:00

open this and close it on the other side

72:05

write plus

72:06

and name of the key

72:10

and then another plus and now we have a

72:13

string variable inside of our log

72:17

warning we save that we go back into

72:20

unity and when we click on play

72:23

we should see here that it's space

72:26

well that wasn't very helpful because we

72:28

don't know if it worked so let's change

72:30

this from space to

72:33

enter let's make this also all

72:36

capitalized save that

72:38

go back into unity

72:41

click on play and this should change to

72:43

enter

72:44

and it did

72:45

so you can begin to see how flexible

72:49

using variable makes our code so instead

72:52

of going and looking for every single

72:55

name we can simply add a variable and

72:58

change it from the top and all

73:00

subsequent uses of it and our code will

73:04

change so

73:05

what now well i think you know because

73:08

it's time for your challenge and your

73:11

challenge is to create your own variable

73:14

so you need to create a variable of type

73:17

string and use it inside

73:19

inside of the debug.log which we already

73:22

did so go ahead and make your own

73:24

variable

73:26

we are going to create a variable of

73:28

type integer and use it in one of the

73:31

warnings

73:33

and finally we're going to create a

73:35

float and use it inside of the error

73:39

logs so pause the video right now and go

73:43

try and do your best don't worry about

73:45

messing things up that's why we have

73:48

version control

73:49

i'll see you in a second

73:52

okay welcome back so how did you get on

73:55

with that it shouldn't be too hard

73:58

so let's go ahead we've created our

74:00

string we've created our integer now

74:03

it's time for our float variable so

74:06

let's go ahead and create a float what

74:09

should we call this

74:11

we'll call this um

74:13

at a speed

74:15

we'll simply call this speed

74:18

a speed of

74:20

breaking and will make this value

74:24

four point

74:25

or wait we'll make this 6.94

74:30

okay great

74:32

and

74:33

i've made a mistake here it should be

74:35

6.94 f

74:37

okay so let's go ahead and add it here

74:40

in our debug.log error so if you smash

74:43

the keyboard let's look here

74:46

at

74:47

a speed

74:49

of

74:52

let's

74:53

simply add this and what should we write

74:56

here

74:57

speed of breaking

75:00

click another plus

75:01

and now if we go back into

75:04

unity click on play

75:07

it should tell us that if you smash the

75:10

keyboard at a speed of 6.94

75:14

nothing happens you just cry

75:16

okay i hope you enjoyed the video i know

75:19

that the variables and the messages in

75:21

the debug log don't make a lot of sense

75:24

right now but you will see that later on

75:27

it will be very important so

75:30

i'll see you in the next video

75:38

[Music]

75:44

welcome back my fellow game developers

75:47

in this video we are going to be

75:49

responding to our players input

75:52

and that will happen how well if we

75:55

click on play right now we don't see any

75:58

messages until we press the up arrow it

76:01

get it gives us a message that tells us

76:04

up arrow key was pressed and if we press

76:07

the left arrow it tells us left arrow

76:09

key got pressed right arrow

76:12

and the down arrow and we did that using

76:16

using some magic code

76:19

very scary but don't worry about it i

76:21

will take you step by step and in fact

76:24

in this video you are going to do that

76:27

not me so let's get started

76:31

okay so as the title of this video

76:34

suggests we are going to be getting our

76:37

players input and for that we'll use for

76:41

example the up arrow the right arrow or

76:44

the left arrow and based on that we are

76:47

going to print something on our console

76:50

but in this video we'll be doing

76:52

something different because

76:55

my goal in this course is not to

76:57

just

76:59

show you how to create a game i want you

77:02

to become

77:04

an expert problem solver so in this

77:08

video i'm going to tell you the problem

77:10

that we have and i will take you step by

77:13

step on how

77:15

i usually solve my problems

77:18

so first thing we're going to do is

77:20

we're going to think of our problem

77:22

so the main problem is we need to get

77:24

our player's input

77:26

from a certain key that he pressed he or

77:30

she or she of course presses

77:32

so the key words to look for are input

77:35

and key

77:37

and whenever we face something that we

77:40

don't know

77:41

unity has a great documentation site

77:45

so we can actually google it

77:48

so we go into google

77:50

and we simply write input unity

77:54

we get all these search results but what

77:57

we are looking for is the documentation

78:00

which is scripting api input unity

78:03

if we click on that it takes us to

78:06

this documentation so we see that we

78:08

have input we have description you can

78:12

always read all the documentation

78:15

but you're of course

78:16

read it later you don't have to get

78:19

specific in every detail just a glance

78:22

over to see what it has

78:24

so as we scroll down and we know that we

78:26

need a key

78:27

that will tell us what key the player

78:31

pressed we can see that we have multiple

78:33

static methods in here and one of them

78:37

is called get key which returns true

78:40

while the user holds down the key

78:42

identified now as we've said our problem

78:46

is

78:47

doesn't consist of a player holding down

78:50

a key we only want to return something

78:53

or get a response from the player from

78:57

us from the game whenever a player

78:59

clicks

79:00

or presses a button doesn't hold down so

79:03

if we read below it we can see that

79:05

return true during the frame the user

79:09

starts pressing down the key identified

79:11

by name

79:13

this looks like something we could use

79:16

so we click on get key down and it takes

79:18

us yet to another

79:20

unity documentation and here is where we

79:24

begin to read our description which says

79:27

that it returns a true during the frame

79:29

the user starts pressing the down

79:32

identified by name great this is what we

79:36

need

79:37

and

79:38

even if you're if you don't know how to

79:40

actually code it if you scroll down just

79:43

a little bit you can see that we have

79:45

multiple examples of this

79:48

and here we have this amazing example

79:52

which tells us that they are actually

79:54

putting this get key down inside of

79:57

update and using something weird which

80:00

is an if

80:01

with some parentheses and i don't know

80:04

what that is it's so weird it's so

80:06

difficult

80:07

let's not trouble our heads with it

80:09

let's simply copy this

80:12

so we'll copy this

80:14

and of course we'll be explaining if

80:16

conditions later and we go back into our

80:19

visual studio and as they told us in the

80:23

example we will paste it inside of

80:26

update okay great so a small

80:31

i do a small explanation of what we're

80:34

actually doing here so if condition

80:36

works as it says if

80:40

anything inside of

80:41

this place here

80:43

inside of these two brackets is true

80:47

we will execute any code inside of these

80:50

two curly brackets

80:52

don't worry about if conditions if

80:54

you're new to them we'll be explaining

80:56

them in in more

80:58

in-depth in later videos but for now

81:01

paste this inside of update save it and

81:04

let's go back into unity

81:08

click on play

81:10

now we press the space bar

81:13

space key was pressed pressed pressed

81:15

and pressed

81:17

okay great but as we've said we are not

81:21

looking for the space we are actually

81:23

looking for the arrow so how are we

81:26

going to do that well we hope that

81:30

our good friend visual studio will help

81:32

and it will

81:34

so

81:35

if we double click here on space and

81:37

delete it

81:39

delete the little point and if we click

81:42

it again as we see it gives us a lot a

81:46

lot of options

81:48

so what are we looking for we're looking

81:50

for the up arrow so let's write arrow

81:55

and voila it gives us all the options

81:58

that we can use and one of them is the

82:00

up arrow so simply click on tab and now

82:04

it should work when we press the up

82:07

arrow so let's

82:09

remove this and actually instead of

82:11

space

82:13

we write up

82:15

arrow

82:16

okay nope not

82:18

excuse me so save that

82:21

let's go back into unity

82:24

go back into unity clear all of that and

82:27

click on play

82:29

wait for it to compile and now if we

82:31

press the up arrow we should get up

82:34

arrow key was pressed

82:37

okay great one more thing i want to do

82:40

let's comment all of these out

82:44

and the way we do that is with two

82:46

backslashes just as

82:49

we have comments in here just so they

82:52

don't get in the way and now it's time

82:55

for your challenge and your challenge is

82:58

to finish the rest what do i mean by

83:00

finish the rest well now you have to

83:03

finish

83:04

if the player pushes the down arrow

83:07

and if the player pushes the left arrow

83:10

and then small extra challenge for those

83:13

of you

83:14

out there that are very motivated if the

83:17

player pushes the space bar even though

83:19

we've already done it i want to see how

83:22

you do it so pause the video right now

83:25

and get on with the challenge

83:28

okay welcome back how did you get on

83:31

with that

83:32

so

83:33

let's simply go ahead and copy this

83:36

there's no shame in copy pasting code

83:39

even though it's better to find a better

83:41

way to do that

83:43

so

83:44

what will we be using in here we'll be

83:47

using the

83:48

down

83:50

arrow

83:51

and we'll copy this also and save

83:55

ourselves as much time as possible so up

83:58

down arrow and in here we're going to

84:01

use

84:02

the left arrow

84:04

and also copy that

84:07

and just for the sake of being

84:10

even extra nerdy we'll make one for the

84:14

right arrow so right arrow

84:18

copy that

84:20

and here we'll simply write

84:22

arrow

84:24

let's make this

84:25

capital letter save that and now if we

84:28

go back to unity

84:31

and click on play all of this should

84:33

clear and now if we press the up arrow

84:36

we get up arrow key was pressed left

84:38

arrow left arrow key was pressed right

84:41

and down and everything is working fine

84:44

and before we go don't forget to commit

84:48

our changes don't worry about if i have

84:50

some extra changes here these were just

84:53

experiments so stage all

84:56

click on commit and we'll write here

85:00

[Music]

85:01

added

85:02

a couple

85:04

of player

85:06

inputs

85:07

okay so commit that everything is

85:10

working fine it's in our masters and

85:13

i'll see you in the next video

85:16

[Music]

85:22

welcome back my friends to another video

85:25

and this one will be using rigid bodies

85:29

and we'll be using box colliders

85:32

what how are we going to use them we'll

85:34

use them adding components and why are

85:36

we going to use them well because now

85:39

our cubes are not just images they

85:42

actually

85:44

fall and not only do they fall but they

85:46

get cut

85:48

using the platforms that we've created

85:51

so

85:52

let's not waste any more time and let's

85:54

get started

85:57

so now

85:58

if we click on play our cube doesn't do

86:02

anything interesting

86:04

and what we wanted is we want to at

86:06

least make it fall so how do we make

86:10

this cube fall and hence how do we add

86:13

the gravity to it and make it a physical

86:16

real object we do that using a rigid

86:20

body

86:21

and what is a rigid body well rigid body

86:25

control

86:27

allows us to control

86:29

an object's

86:31

position through physics simulation i

86:34

know it's a handful it's big words but

86:37

if you go to unity's documentations

86:40

which i have left you in the resources

86:42

you can actually read all about rigid

86:44

bodies

86:45

and rigid body object will be pulled

86:48

downwards by gravity without adding any

86:52

code which is amazing and exactly what

86:54

we need

86:56

so so if we go back into unity we can

86:59

actually go into our magic cube and if

87:02

we look here on the right to our

87:03

inspector we can see that we have a

87:06

transform we have a sprite renderer and

87:09

we have the cube so transform tells us

87:12

the position that our cube is at the

87:14

sprite renderer actually renders our

87:17

cube so if we turn it off

87:19

it goes away turn it back on it turns

87:22

back and the cube is our script so let's

87:25

make all of these smaller and we have

87:28

here this button which allows us to add

87:31

components so if we click on add

87:33

components

87:35

we can actually search for rigid body

87:38

and we have two rigid bodies one is

87:40

rigid body which is used for the 3d

87:42

world and the rigid body that we will

87:45

need which is rigid body 2d

87:47

click on rigid body to d

87:50

and now

87:52

we can see that we have a lot of options

87:54

and information and constraints and body

87:57

type and mass

87:59

don't worry about all of these

88:01

we won't be using all of them but if you

88:04

are interested

88:05

and you want to go deep into the rigid

88:07

body subject you can read all about them

88:09

in the unity documentation

88:11

one thing i will be glancing over is the

88:16

body type which we have dynamic

88:18

kinematic and static now later on we

88:22

will delve even deeper into these three

88:25

but for now what you need to understand

88:27

is that dynamic is when our

88:30

body is

88:32

subjected entirely to the physics world

88:35

around him kinematic is when our body is

88:38

not affected by gravity but could be

88:41

affected by other forces and static is

88:44

an object that does not move at all

88:46

whatever happens to him

88:48

so we need our cube to be for now

88:51

dynamic so we've added a rigid body

88:54

let's save that

88:56

and let's click on play and see what

88:58

happens if we click on play

89:01

our bad d or our magic cube goes down

89:05

and leaves our scene and we have no idea

89:08

where it went

89:09

it goes away into i don't know what's

89:11

called down there maybe hell or anything

89:14

but it disappears so

89:16

how are we going to hold it because for

89:19

now it's not that magic we'll do that

89:22

using colliders and what are colliders

89:25

what is a collider

89:28

a collider makes it possible for objects

89:31

to interact and hence collide with each

89:35

other so whenever our collider or or

89:39

whenever our body has a collider and it

89:41

touches another body that has a collider

89:44

they will

89:45

collide and stop each other

89:48

we'll use it to catch objects that are

89:50

following are falling because of gravity

89:54

so we're going to use this collider in

89:57

order to

89:59

catch the object that we have so let's

90:01

go back into unity

90:04

and close down this rigid body and add

90:06

another component and we can actually

90:10

search for collider

90:12

and as you can see we immediately have

90:14

tons of options we have box colliders we

90:16

have box colliders to the capsule

90:19

capsule to the circle circle to d so

90:22

because we're using our cube or square

90:25

we'll be using a box collider 2d which

90:28

is ultra simple

90:30

and as you can see we also have tons and

90:33

tons of options you can read all about

90:36

them i of course left it in the

90:38

resources

90:39

but one thing we need to focus on is

90:42

this is trigger and this will be useful

90:45

later on in the course but for now let's

90:48

just zoom in and see what we have

90:51

we can actually see our

90:54

box collider it's green it's a green

90:57

line all around our box but we cannot

91:00

see it right now

91:01

the way to see it is if we click here on

91:04

the edit collider

91:06

and we can actually make this collider

91:08

bigger make it this way and this way and

91:12

actually make it outside so this is the

91:15

colliders this is actually where our

91:18

object will be colliding with other

91:21

objects so let's reset all of that

91:24

and let's see what happens if we click

91:26

on play so exciting

91:28

and then

91:30

nothing happens why is that it's because

91:33

you have a challenge and your challenge

91:36

is to catch the falling cube don't worry

91:39

i won't leave you alone because first of

91:42

all you need to create another cube and

91:45

size it to platform size what do i mean

91:48

by that well you need to make our

91:51

platform

91:52

from

91:53

this end right here all the way to the

91:57

other end in order to catch our cue

92:01

so let's continue with the hints create

92:03

another cube and make it a platform

92:07

add a rigid body and don't forget to

92:10

change the rigid body type to static

92:13

and finally add a collider to our

92:15

platform and catch our cube so pause the

92:19

video right now give it your full

92:21

attention give it your full

92:22

concentration

92:24

and don't worry about making mistakes

92:27

because mistakes are the best part of

92:30

learning

92:31

you

92:32

it's either you

92:34

do something well

92:35

or you do it wrong and learn from it so

92:39

take your time and do the challenge

92:42

okay welcome back how did you get around

92:45

with that i hope you didn't just stare

92:47

at the screen for like five seconds

92:49

until the video continued

92:52

okay so now we take our magic cube and

92:55

what we'll do is we'll duplicate it and

92:57

we can duplicate it in two ways we can

93:00

either right click on here and do go to

93:02

duplicate

93:04

which will create another gamecube or we

93:06

can simply click on ctrl d and now we

93:10

have another cube if we take it here

93:12

below

93:13

let's make this cube a little bit bigger

93:16

and the way we're going to do that is by

93:18

scaling it so here we have the scale in

93:21

the x direction and we have scaling in

93:24

the y direction and in this z but

93:26

because it's

93:27

2d it won't scale anyways

93:30

so let's bring back y to

93:33

1

93:34

and let's increase

93:36

the x scale until it fits between the

93:39

two

93:41

sides of our game now we have a platform

93:45

and let's differentiate a bit between

93:48

them so let's make this platform a bit

93:50

darker

93:51

we can change the color in our spread

93:53

sprite renderer here we have the color

93:56

and if we click on it we can make it a

93:59

bit grayish or blackish

94:03

so let's make it

94:05

black

94:07

and we'll make the square here let's

94:10

make it

94:12

keep it white or make it a bit gray

94:15

let's see

94:16

maybe let's just keep it white and let's

94:19

change the background oh very fun so we

94:21

can go into camera and actually change

94:24

the background color which will make

94:27

grey

94:28

okay seems great enough and let's lower

94:33

this magic cube actually let's change

94:34

its name to

94:36

platform oops

94:38

wait

94:41

platform and now we have our platform

94:44

let's lower this down

94:47

and these are the edges of our camera

94:50

so now if we

94:51

save that

94:53

and oh i forgot something good thing i

94:56

remember to be click on platform and

94:58

don't forget to make this static or else

95:01

it will just fall away fall down into

95:04

whatever down is click on play

95:07

and hopefully yes it holds amazing

95:11

i hope you liked the video i hope you

95:13

did everything

95:15

and

95:16

commit everything we done

95:19

so committed

95:22

added

95:23

well actually

95:24

made my

95:26

magic cube fall

95:29

and held it

95:31

with a

95:33

platform using

95:35

rigid body

95:37

and colliders a great

95:40

so stage all

95:42

comment

95:43

and i'll see you in the next video

95:51

[Music]

95:57

welcome back guys to a brand new video

96:01

and as advertised in this video when we

96:04

click play

96:06

our cue becomes magic how's that well if

96:10

we press up he jumps if we press left he

96:13

goes left if we press right he goes

96:15

right and if we go up up up up we can

96:18

actually press down down down down down

96:19

and make him come back faster to earth

96:23

so let's get started

96:26

okay so first thing we'll do

96:29

is we need a reference to our rigid body

96:33

what do i mean by reference to our rigid

96:35

body and why do we need it so reference

96:38

to a rigid body means that we'll

96:41

write up here public

96:44

and don't worry about public we'll

96:46

explain it later but for now public

96:48

means anybody can use it so public

96:54

rigid body it's a variable of type rigid

96:58

body

96:59

and we'll call this my

97:02

rigid

97:03

body

97:04

2d

97:05

okay

97:06

save that now how are we going to tell

97:10

this that it is the rigid body on

97:13

my current object

97:15

well if we go back into unity

97:18

clear those messages pesky warnings and

97:21

if we click on cube

97:23

right here in the inspector we can see

97:25

that now now we have an empty slot for a

97:28

rigid body

97:29

so if we click on the little circle to

97:32

the right we can see that we have the

97:33

magic cube or the rigid body of the

97:36

platform so let's go ahead and click on

97:39

the rigid body on our cue

97:42

double click on that

97:44

and save it one thing i just noticed is

97:47

that if we click on our platform

97:51

oh

97:53

it's actually we made a mistake we

97:55

shouldn't add the rigid body in fact we

97:57

should

97:58

remove the

98:00

cube

98:01

so let's remove the cube component from

98:03

the platform because we don't need it to

98:06

move that's something we should have

98:07

done in the previous video but that's no

98:10

problem go back to cube and now we add a

98:13

rigid body which is magic cube

98:16

excellent so save that

98:19

now we have a reference to our cube

98:23

next thing

98:24

we're going to do is we're going to add

98:27

velocity to our rigid body so if you

98:30

went through the documentation of the

98:32

rigid body in unity

98:34

in unity documentation

98:36

i think you have noticed or maybe you

98:39

didn't but there is a

98:42

component or how do we call it a

98:44

property and my rigid body that we can

98:47

use in order to manipulate the velocity

98:50

so now

98:51

our arrow keys no longer print things to

98:54

the console our arrow keys now actually

98:57

manipulate the velocity of our rigid

99:00

body

99:01

so let's do that so in order to access

99:04

the velocity we will write my rigid body

99:06

to d

99:07

which we now have a reference for

99:10

dot

99:11

velocity

99:12

velocity

99:14

now if we glance over velocity we see

99:17

and actually visual studio tells us that

99:20

it's a vector 2

99:22

what is a vector 2 well a vector 2 is a

99:25

vector into the space so that means

99:29

it has the x-coordinates and the

99:33

y-coordinates now you should be pretty

99:35

familiar with

99:37

x and y-coordinates from school it's not

99:40

too hard of a math but

99:43

it

99:44

should be now i i will of course leave

99:46

some resources in the

99:50

video attached to this video where you

99:52

can check out everything about vector

99:54

tools don't worry about it

99:56

it's pretty simple to create a vector2

99:59

we all we need to do is write new

100:03

vector2

100:04

and open the brackets nothing too fancy

100:08

and inside those brackets we can

100:09

actually go

100:11

through multiple parameters that this

100:13

vector 2 can take and it takes a float x

100:17

and a float y so

100:20

how do we want to move it in our case we

100:23

are pressing the up arrow that means we

100:25

want the

100:26

box to move upwards and not move to any

100:30

side to side so how do we do that

100:33

we simply

100:35

write 0f in the x direction and 10 f

100:40

in the

100:41

y direction so 10 f means it's a float

100:45

because

100:46

our parameters told us that the rigid

100:48

body takes floats so let's go ahead and

100:52

continue the down arrow now even though

100:55

down arrow i don't think we'll be

100:57

needing it but for practices

100:59

practice

101:01

practice reasons we are going to add it

101:03

and

101:05

being this is down instead of 10 f we'll

101:08

make this minus 10 f so

101:10

save that let's go into unity

101:14

and see if

101:16

something actually worked so click on

101:18

play

101:19

our cube falls to the ground and if we

101:21

press the up arrow he actually jumps and

101:24

then falls down so if you press up up

101:27

and then down down he falls faster

101:30

excellent job and now you know what time

101:33

it is it's time for your challenge

101:36

complete the magic so

101:39

you have to finish adding velocity using

101:41

the left arrow and then you need to

101:44

finish adding velocity using the right

101:47

arrow so pause the video right now go

101:50

ahead and do the challenge welcome back

101:53

how did you get on with that i hope

101:55

everything went well

101:57

it's very easy let's simply copy that

102:01

and now when we add it to left

102:04

we will have

102:05

0 f in the y direction and we will add

102:10

it

102:10

minus

102:12

let's say 10 f let's keep it then

102:15

and in the case of the right arrow

102:18

we'll add 10 f

102:21

in the x directions

102:23

direction and zero f in the

102:27

y direction

102:29

go back into unity click on play and now

102:33

if we plus press on the left arrow we

102:35

should move left right arrow we move

102:37

right up up up down down

102:40

everything works perfectly fine

102:43

final step as always i don't think i

102:46

will keep doing this but for now just to

102:49

get you in the habit of doing it so

102:51

assets what will should we call this

102:54

well

102:55

made my cube

102:58

move

103:00

left

103:01

up down and

103:04

right

103:05

based on the

103:06

arrows

103:08

with an exclamation mark

103:10

so commit that and i'll see you in the

103:13

next video

103:15

[Music]

103:20

welcome back everyone to another video

103:23

as the title suggests we are going to be

103:26

learning about if conditions and we are

103:29

going to learn learn how we can

103:31

manipulate them so if we click on play

103:34

right here

103:35

if our box moves to the left

103:38

our console prints that our cube is out

103:40

of bounds to the left and if we move to

103:42

the right it tells us that our cube is

103:45

out of bounds to the right side and the

103:48

best part is if we jump it tells us that

103:50

our cube is out of mind bound to the

103:53

upper side so how are we gonna do this

103:56

using if statements so put your

103:58

concentration caps on and let's get

104:00

started

104:02

okay so before we start let's talk about

104:04

what if conditions are

104:07

why we use them

104:09

and their structure so

104:12

conditional if statements

104:14

they are as the name suggests they are

104:17

code that we execute only under certain

104:21

conditions

104:22

so this is the structure of an if

104:24

condition we've used it before in our

104:26

arrows and player inputs

104:29

so

104:30

if

104:31

some condition that needs to be true

104:35

is true we execute whatever code is

104:38

inside these curly brackets

104:41

so if we put in a boolean as we've said

104:45

a boolean can either be false or it can

104:47

be true so if that boolean is true we

104:50

execute the code that is inside the

104:52

curly brackets

104:54

now if this statement happens to not be

104:56

true we will simply just avoid or not

105:00

even consider the if not even consider

105:03

the code inside of the if statement

105:06

but if we add another else if and as its

105:09

name suggests is if the

105:12

upper condition does not

105:14

is not true

105:15

we check for a second condition which is

105:18

some other condition that is true and if

105:21

that

105:22

statement or condition is true we

105:24

execute the code inside of these curly

105:27

brackets and if both statements are

105:30

false

105:31

then we finally use something called

105:34

else and this does not have to be any

105:36

nothing has to be true in order for this

105:38

code to be executed only all other if

105:43

conditions above it should be false now

105:46

we've used this else our if condition

105:49

before we've used it in our code

105:52

when we tried to

105:54

get the key down from the

105:56

player so how does this exactly work

105:59

let's zoom in a bit so

106:01

input

106:02

this input which is a class in unity

106:06

uses the function or method get key down

106:10

so if you hover over the get key down

106:13

you can see that it's a boolean and it

106:15

returns true during the frame the user

106:18

starts pressing down so whenever our

106:20

player presses the up arrow as we've

106:23

used as we've said told it here and we

106:26

did it using key code which is another

106:29

function in unity dot

106:32

up arrow

106:34

if he presses the the up arrow

106:37

it tells the get key down that this

106:39

during this frame the up arrow key was

106:42

pressed and it returns true that makes

106:45

our cue that makes this

106:48

code right here execute and moves our

106:51

cue and the same is true whenever we

106:55

use the other if statements

106:58

so now what we are going to do is we are

107:00

going to be creating our own if

107:03

condition and we are going to do that

107:07

in our case for the game so for now if

107:10

we click on play

107:12

and we move our cube from side to side

107:14

whenever he gets out of boundaries he

107:17

falls down from our platform and what we

107:20

want to do first thing we'll make our

107:22

platform just a little bit bigger

107:24

so we'll increase its scale

107:27

make it just a little bit bigger to give

107:29

our cube a place instead of just falling

107:32

into whatever down is

107:34

and now we're going to check for the

107:37

coordinates on its on this cube so this

107:40

white frame right here is what our game

107:43

actually sees and if we dock our game

107:46

view next to our scene view oh and as

107:49

you can see it gets smaller to fix that

107:52

we can simply go into game and click on

107:55

this

107:56

uh right here

107:58

and simply make it into 16 by nine and

108:01

this should always keep our frame at the

108:04

same dimensions

108:06

so now if we go into our scene let's

108:08

make this a little bit wider

108:10

and click on our game cube or magic cube

108:13

and move it you can see at the top right

108:16

in the inspector that the position

108:19

changes and this value can actually be

108:22

accessed so whenever our cubes goes

108:25

outside the boundary so let's say it

108:28

should be right about here which is nine

108:30

9.42

108:33

so whenever it goes outside the boundary

108:35

we want to print something to our

108:38

console and the same holds true whenever

108:41

we go to the other side which is what

108:44

should be

108:45

9.40 will settle for 9.5

108:49

okay so how are we going to do that well

108:52

using the structure of if conditions

108:54

that we just learned

108:56

so let's go ahead save this

108:58

and go back into our visual studio and

109:01

we'll do this inside of update

109:04

so

109:05

what are we going to do we want to check

109:08

if

109:08

the cube has moved outside the right

109:11

boundary

109:12

so if

109:15

what should be right here first thing

109:16

we'll need to do is access the transform

109:19

of our

109:20

cube or game object so it's transform

109:24

simply write transfer dot

109:26

position

109:28

and we're not looking for any position

109:31

we are looking specifically for the x

109:34

position so it's x

109:36

so if transform dot position dot x

109:40

is a greater than 9.5 f because remember

109:45

it's a float

109:46

then inside of the if statement we want

109:49

to execute some code and for now we are

109:52

simply going to print to our console so

109:55

we'll write debug

109:57

dot log let's make this a warning just

110:00

for fun

110:02

so debug dot

110:04

log warning

110:07

so we should write something inside of

110:09

it our

110:10

cube

110:11

is out of

110:13

bounds to the

110:16

right side

110:18

with two exclamation points to make it a

110:20

bit more dramatic so save that

110:23

go back into unity

110:26

wait for it to compile and understand

110:29

what is happening and now clear all of

110:31

that click on play

110:34

and now if we move to the right side as

110:37

you can see our cube is out of bounds to

110:40

the right side and the more we move but

110:43

if we move to the left nothing happens

110:45

so pause that

110:47

and now

110:50

we'll make a an else if statement

110:54

so

110:55

else

110:57

if

110:59

and inside of it

111:00

for our else if statement we're going to

111:03

check if our cube goes to the other side

111:07

of our

111:08

screen so it's transform again we access

111:10

the position and we need only the x and

111:14

now we're going to check if it's smaller

111:17

than

111:18

minus 9.5 f

111:21

and in this case we're going to also

111:24

print a warning

111:27

which will be our cube is out of bounds

111:29

to the

111:30

left

111:31

side with two exclamation points

111:34

so let's make this a little bit neater

111:37

ctrl s to save all of that go back into

111:41

unity

111:42

wait for it to compile clear everything

111:45

click on play and now if we go to the

111:48

left side with our cube it tells us that

111:51

our cube is out of bounds to the left

111:54

and on the right side it tells us that

111:56

our cube was out of bound to the right

111:59

but now if we jump with our cube

112:03

nothing happens because it's time for

112:07

your challenge and your challenge is to

112:10

finish the last if statement so

112:12

finish if statement when our player goes

112:15

out from the top of our screen

112:18

and i'll give you a couple of hints

112:21

we'll need to move the cube around in

112:23

our scene and understand the top

112:25

boundary

112:26

and we'll also need to use the if

112:29

statement to print to our console so

112:32

pause the video right now take your time

112:34

with this challenge i'll see you in a

112:36

bit

112:38

okay welcome back so let's clear this up

112:42

and let's see our upper bound so if we

112:44

move our cube

112:46

we can see on the right here that we

112:48

have the y position changing and if we

112:51

take the y coordinates and check for

112:55

them at about 5.5 our cube leaves the

113:00

camera view

113:01

okay great so let's go back into our

113:03

visual studio and write another else

113:08

if

113:08

statement and else if our transform that

113:12

position and now instead of the x we're

113:15

going to be using our

113:17

y

113:18

so if our transform.position.y

113:22

is greater than 5.5

113:25

f

113:27

we will print another warning

113:31

in here and this warning our cube is out

113:34

of bounds to the

113:37

upper side also the exclamation points

113:40

save that go back into unity

113:43

and let's wait for it to understand what

113:45

we've done click on play

113:49

and now if we jump jump jump and we get

113:52

out of bounds it tells us that our cube

113:54

is out of bounds to the upper side

113:57

okay so final step let's move out of

114:00

play go back into our source tree

114:04

and now we can commit everything so

114:07

stage all

114:08

click on commit and we'll call this

114:12

adding

114:13

if

114:14

statements

114:16

to my game

114:19

click on commit

114:21

and i'll see you in the next video

114:24

[Music]

114:30

welcome back everyone to another video

114:34

in this video we are not be doing a lot

114:37

of coding but we will be restructuring

114:40

our code how are we going to do that

114:42

well as you see our update method is a

114:44

bit different because we extracted all

114:48

of the

114:50

things that are related so for example

114:52

now we have a method that is moving our

114:55

cube and it's

114:57

right here and we have another method

115:00

that is out of bounds in our printer not

115:03

only that we've also created a public

115:05

method which is printing from outside

115:08

which also has a parameter so exciting

115:12

and it returns a string and it's used

115:16

not inside of cube it's used in platform

115:19

a new script that we've created i'm so

115:21

excited for this video i hope you are

115:24

too so let's not waste any more time and

115:27

let's get started

115:29

okay so

115:31

if we look right now at our start and

115:34

update methods we can see that they are

115:37

kind of cluttered and there are things

115:40

that are not related to each other so

115:43

for example we have

115:44

all of these if conditions that relate

115:47

to our cube movement and we have them

115:50

right next to the if conditions we've

115:53

created to understand the boundaries of

115:56

our queue

115:57

so we need to restructure them in a way

116:01

and to make it look more appealing to

116:03

the eye

116:04

so we're going to do that using methods

116:08

so what are methods well method

116:11

structure are kind of like this just

116:14

like we have the start method and the

116:16

update method we can also create our own

116:20

method and they kind of look like

116:24

variables but they are also kind of

116:26

different so we have first first of all

116:29

is the

116:31

access type and this is the

116:33

accessibility so we have two access

116:36

types it can be either private or it can

116:39

be public and we are going to use both

116:42

in our project so private is when a

116:47

method is only used inside of its class

116:51

so for example if you create a public

116:53

method inside of cube

116:55

only cube can use that method but if you

116:58

create a public method

117:01

other scripts can use your method also

117:04

then we have the return type and for now

117:08

we've only used the void which means

117:10

that we return nothing we can have a

117:14

return type of integer for example where

117:16

a

117:17

certain method returns an integer it can

117:20

also return a string and it can return

117:23

other things

117:25

we also have a method name so it

117:28

the method names should always reflect

117:31

what the method actually does

117:34

and as a convenience just as we name our

117:37

variables the first word will always is

117:41

not capitalized when we are naming

117:43

methods our first word is always

117:46

capitalized and all subsequent words are

117:49

also capitalized

117:51

and finally we have parameters and we

117:54

have a when a parameter has nothing

117:56

inside of it that means we pass nothing

117:59

and what parameters are they are like

118:02

variables that we pass to our method and

118:05

we can use them inside of our method

118:08

only so

118:12

how are we going to use this method

118:14

structure well we're going to use it

118:16

inside of our

118:18

the code right here so

118:22

let's begin by restructuring some things

118:24

so

118:25

as an example i will show you how

118:28

much more efficient our code becomes so

118:31

let's remove all of these

118:34

comments right here and as you can see

118:37

that every time we need to comment these

118:40

debug logs we need to go there and do

118:43

them one by one well we can actually

118:46

use all of these

118:48

if you highlight them and of course

118:50

you're using visual studio and you right

118:53

click on them you can see that we have

118:55

something up called quick action and

118:58

refactoring so if you click on that it

119:01

tells you if you want to either extract

119:04

it to a local function or extract it to

119:06

a method so if we extract it to a method

119:10

and by the way the difference between a

119:12

function and a method you can actually

119:14

use them interchangeably and however you

119:17

want but functions are usually

119:20

methods that are inside of a

119:24

another method but a

119:26

method is a method that is outside

119:30

the method we're currently doing so it's

119:32

a bit confusing you can use both of them

119:34

interchangeably don't worry about it so

119:37

what are we going to name this

119:39

method here

119:40

and we are going to call it

119:44

printing

119:46

to

119:47

our printing wait to

119:50

our

119:52

console

119:54

and click on

119:55

enter and now we have this function or

119:59

method right here and as you can see

120:01

it's a private method that doesn't

120:03

return anything because it's void

120:06

and now if we want to comment that out

120:08

we can simply comment this function out

120:11

and all of it is commented out and it

120:13

won't be printing to our console so this

120:16

is the first benefit of using

120:19

uh methods so let's go ahead and

120:22

put this under update so if we click on

120:25

ctrl x to cut it

120:28

and we'll put it below update

120:31

i like to put update right below the

120:34

start method to have a nice and cohesive

120:37

structure to our code

120:39

next thing we're going to do is we're

120:40

going to extract

120:43

two another methods so first of all

120:45

we're going to highlight all of the

120:48

if conditions in our up for our

120:52

for moving our cube so highlight all of

120:54

them right click create a

120:57

extract a method we'll call this method

121:01

moving

121:02

our

121:04

cube

121:06

and we'll also extract this method and

121:09

we'll right-click

121:11

go to extract method and we'll call this

121:14

method what should we call this

121:17

out

121:18

of

121:20

bounds

121:22

printer

121:24

okay

121:25

so now oh sorry for that

121:28

get back to zoom in a bit so now as you

121:31

can see our update method is very

121:33

cohesive and it

121:35

we can easily see what our update method

121:38

does so it is moving our cube and it out

121:42

of bounds printer it checks for out of

121:45

bounds whenever our cube is out of

121:47

bounds it prints something to our

121:50

console so now you can see that we have

121:52

this

121:53

method right here and another one

121:56

right here and finally we have the

121:59

printing to our console excellent

122:02

now we are going to create a second

122:05

script and create a public method just

122:09

to demonstrate how everything is working

122:12

so

122:13

first thing we'll do is we'll create a

122:15

public method just under update and

122:18

we'll call this

122:19

well first of all let's make a public

122:22

we'll make this a void

122:24

because we don't want it returning

122:26

anything for now

122:28

public void

122:32

no we'll use it

122:34

we'll call this printing

122:36

from

122:38

outside

122:39

okay

122:40

you don't have to make your

122:42

method names that long but just for the

122:45

sake of giving an example so

122:48

what this function will do it will

122:49

simply

122:50

print

122:52

something

122:53

or a certain message that will have

122:57

hello

122:58

from the

123:00

other side i don't know why from is

123:03

capitalized it doesn't have to be so

123:05

it's hello from the other side

123:08

let's go back into unity

123:10

click on platform because it's the only

123:13

other object that we have besides the

123:15

camera let's add a component and let's

123:18

create a

123:20

platform

123:22

plot

123:24

form script so new script platform

123:28

excellent let's go ahead and create it

123:31

and it in a bit it should be added and

123:34

now if we

123:35

now we have it in our project so double

123:37

click on it and it should open in

123:40

our visual studio as you can see we

123:43

already have the void update method and

123:46

the void start method

123:48

now inside of start

123:50

we are going to get a reference to our

123:54

cube script and use the public method

123:57

that it has

123:58

and how are we going to do that well

124:00

we're going to do that using something

124:02

called

124:03

find

124:04

object of type

124:07

and object of type

124:09

has these two

124:11

operators right here that

124:13

we need inside of it to tell which

124:15

script we are going to use so it finds

124:17

the object of type

124:19

cube

124:21

and visual studio always helpful and now

124:24

if we click on dot

124:27

we can see that we can use anything that

124:30

is inside of the cube

124:32

so if we for example want to access the

124:35

start method we can't

124:37

but if we want to print as you can see

124:40

it gives us the printing from outside

124:42

method

124:44

because it is public so if we save that

124:48

and go back into youtube unity

124:52

and let's also save our scene and click

124:55

on play and before we do that let's

124:57

clear this up and as soon as we click on

125:00

play

125:01

hello from the other side

125:04

how cool is that so we've created a

125:07

function or a method that is inside of

125:09

the cube

125:11

but we are using it inside of the

125:14

platform

125:16

that is so cool and this actually is the

125:18

basis and it's very crucial because

125:21

we're going to be using it a lot in our

125:24

game in the next sections

125:26

so

125:27

your challenge

125:29

is to create your own method

125:32

you will create a simple method with a

125:34

string return type so instead of void

125:37

you will have it as a string type

125:40

you will also give it an integer

125:42

parameter

125:44

and you will use it with the string and

125:47

return it

125:48

so it's a bit of a big challenge but i

125:51

think you are ready for it

125:53

and a small hint use

125:55

to string

125:57

and it will require a bit of research to

125:59

understand and do the challenge take

126:02

your time don't don't be afraid of

126:04

making mistakes as i've told you

126:07

trying and failing is not the end of the

126:09

world so i'll see you in a bit

126:14

okay welcome back so

126:18

now we are going to

126:20

change our

126:22

uh

126:23

method just a little bit so instead of

126:25

void we'll make this a string

126:29

and it currently doesn't take any

126:31

parameter so we'll give it a parameter

126:34

which is an integer

126:36

and we'll simply name this integer value

126:38

to not be over complicated but as you

126:41

can see right here

126:43

we have a squiggly red line that means

126:45

that our function is not working

126:48

probably properly

126:50

why is that because

126:52

it has a return type which is a string

126:55

but it's actually not returning anything

126:58

so how do we fix that

127:00

well we need to write here return and we

127:04

need to return a certain value

127:07

and what that value is well it needs to

127:10

be a string so let's go ahead and create

127:13

a variable inside of our printing from

127:16

outside

127:17

so this variable will be a string we'll

127:20

call this

127:21

variable

127:23

printing

127:25

something

127:27

and what will have it print well

127:31

the

127:32

value

127:34

we

127:35

were

127:36

sent

127:37

is

127:39

and now we can use this parameter that

127:43

we've been sent from the other side

127:46

and now in return we will

127:49

return print something and that should

127:52

fix

127:52

our squiggly red line

127:54

problem

127:56

but because we've given it a parameter

127:59

in here

128:00

where we call it from should also give

128:03

it a certain parameter so we can we have

128:07

to give it an integer and that integer

128:09

let's say

128:11

will be 8 or 4 or anything or you can

128:14

even create

128:15

a variable right here we'll call it an

128:18

integer we'll call this

128:20

value to

128:23

send and it will be equal to let's say 9

128:29

and in here we'll

128:32

send the value to send

128:35

save that this actually returns a string

128:39

so let's put it inside of a string

128:42

reference which we'll call

128:44

string from

128:47

out

128:48

outside

128:50

equals

128:51

and now we'll simply

128:53

debug dot log

128:56

and we'll be printing the string from

128:58

outside

129:00

so close that

129:02

save that

129:03

go back into unity

129:06

so clear everything click on play

129:09

and now the value we were sent is nine

129:13

excellent job

129:15

and one thing i want to make clear is

129:17

that because this is a string and this

129:21

method returns a string we can actually

129:24

directly put it inside of our lock

129:28

excellent job everyone i hope the

129:30

challenge wasn't too hard i thought it

129:33

was a little bit step up and it needs a

129:36

little bit of research but

129:38

i hope you tried your best and as always

129:41

before we go

129:42

we need to stage all

129:45

comment

129:48

created my first

129:50

public

129:51

method with

129:53

return

129:55

type

129:57

commit that and i'll see you in the next

130:00

video

130:07

[Music]

130:12

welcome back everyone to a new and very

130:15

exciting video in this one we are going

130:18

to learn about prefabs not only that we

130:21

will learn about prefabs how we can use

130:25

them from scene to scene here you can

130:27

see that we have a diamond with

130:29

something called a polygon collider we

130:32

also have this magic cube and a small

130:35

circle but actually the circle moves

130:38

with our cube because it is a child of

130:41

that cube

130:42

we can also we've also created a second

130:45

level level one and level two here we

130:48

have three cubes as you can see and for

130:51

some reason they are blue and we'll see

130:54

why they are blue we also have a diamond

130:56

right here and if we click on play all

130:59

of them fall down and

131:02

that's it so it's so exciting

131:05

i'll see you in a bit

131:08

okay so what is a prefab

131:12

well basically it's a template for a

131:16

certain game object so

131:19

if we

131:20

created a game object with all its

131:22

components and its script and its

131:24

position

131:26

we can create a template from it

131:28

to create other similar game objects

131:32

prefab system allows you to store a game

131:36

object with all its properties so let's

131:39

say our prefab has a collider it has a

131:43

rigid body and it has a script whenever

131:46

you create a prefab from said game

131:49

object you will have the same properties

131:52

in it

131:54

so why do we use it for well we can

131:57

reuse a game object configured in a

131:59

particular way

132:01

we can edit many objects at once

132:05

and we can use the same object in

132:07

different different scenes much easier

132:10

so let's go ahead and demonstrate these

132:13

three uses

132:15

so

132:16

creating a prefab is actually very very

132:20

very simple you all you need to do is

132:22

simply click on the thing that you want

132:24

to prefab so for example we want to

132:26

prefab our magic cube

132:28

click on it and drag it

132:31

into our project and now we have a

132:34

prefab of our cube and you know it's a

132:37

prefab by looking up at the hierarchy

132:40

and you can distinguish it by because

132:42

it's a bit more blue

132:45

excellent so now what can we do with our

132:47

prefab

132:48

if we click on it you can see that it

132:50

has the same properties

132:53

as

132:54

the cube in our scene

132:56

and now if we click on the prefab and

132:59

drag it into our scene you can see that

133:01

we can create three

133:04

beautiful magic cubes extremely easily

133:08

and this is very helpful in many ways

133:12

so let's demonstrate how prefabs work so

133:15

let's say we

133:16

click on this magic cube which we see in

133:18

the hierarchy is number one

133:21

so let's say we want to change its color

133:24

so if we go into our sprite renderer and

133:26

choose color and let's make it red so

133:30

now we have a red magic cube

133:33

we save that and you see that the other

133:36

two magic cubes are still white and by

133:40

the way these cubes are called instant

133:42

instances of prefab

133:45

and if you look closely here in our

133:47

inspector you can see that we have

133:49

another tab open

133:52

so we have the open which opens our

133:54

prefab which is the magic cube we can

133:57

select

133:58

the prefab and we can overwrite and what

134:01

this does it applies whatever changes

134:04

that we've made to our current instance

134:06

to our prefab so the things that have

134:09

changed you can see that they are also

134:11

highlighted in a

134:13

blue color right here and we changed the

134:17

color so if we click on override and

134:19

click on apply all

134:21

what should happen

134:22

is that all of the other instances of

134:25

that cube change to red and down here in

134:29

our project you can see that our magic

134:31

cube is red now

134:33

that is

134:35

very cool and you can start to see how

134:37

helpful that is

134:39

so let's say we change back

134:41

change back the instance to white

134:44

let's take another cube and change that

134:46

to

134:47

green

134:48

so now

134:50

if we apply this to

134:52

our prefab what do you think should

134:54

happen will all of them turn green or

134:57

will only the one that is the red turn

134:59

to green

135:00

let's try that apply and oops as you can

135:03

see that only the prefab that was

135:07

originally or the instance of prefab

135:10

that was still the same as the original

135:13

is changed to green but the ones that

135:16

we've also modified don't change back so

135:19

private prefabs are a bit tricky but

135:22

they are very helpful

135:24

so for example let's go ahead and delete

135:26

those three cubes

135:29

let's go into scenes and let's simply

135:32

duplicate our current scene by that we

135:35

create a second scene let's rename this

135:38

to

135:40

level

135:41

two

135:42

and our original scene will be level one

135:46

so now yes it asks you for a reload

135:49

simply click on yes so now in level one

135:52

we have these three cubes and in level

135:54

two apparently we also have these three

135:57

cubes so let's go ahead and delete them

136:01

save that so in level one we have the

136:04

cubes in level two

136:06

we don't have cubes

136:08

so what are we going to do about it well

136:11

instead of going to level one

136:14

and duplicating or copying the cubes we

136:17

can simply go to our project and we have

136:19

a magic cube and we can

136:21

add it

136:22

easy as pi

136:24

right into our scene and now we have a

136:27

cube a magic cube in our scene

136:30

okay great so that's a prefab now what

136:34

are children well

136:36

let's go ahead and create go to assets

136:40

and the create

136:42

a sprite and the sprite will be a circle

136:46

so now we have this

136:48

let's say

136:49

magic

136:51

child circle

136:52

okay so magic child circle we can go

136:56

ahead and add this magic child circle to

136:58

our scene and by the way this magic cube

137:01

is the prefab this is just the sprite

137:05

by the way we can also organize all of

137:07

this so if we create a folder called

137:09

this sprites

137:11

we can put both of these into sprites we

137:14

can also go ahead and create another

137:17

folder called this

137:19

scripts

137:20

and now we have these scripts inside of

137:23

the folder scripts and if we add another

137:26

prefab we can also create a folder for

137:28

the prefabs

137:30

so now we have this magic child circle

137:34

why do we call it the child circle well

137:36

because we are going to child it to our

137:38

magic cube and we do that if by simply

137:43

taking our

137:44

magic child circle and dragging it right

137:47

under our magic cube and now it's a

137:50

child

137:51

now what does child mean if we click on

137:54

the circle we can move it as we always

137:58

do but if we click on the magic cube

138:01

and we move it you can see that the

138:03

circle moves with it that means it is a

138:08

child and if we scale our cube

138:12

our circle also scales

138:14

and if we scale in the y direction it

138:17

also scales if we rotate

138:20

so let's see if we rotate it

138:22

the circle also rotates and these are

138:25

properties of a child

138:28

it grows with its parent

138:30

and the parent is magic cube so it grows

138:33

with its parent it shrinks with its

138:35

parent it moves and behaves just as its

138:38

parent does and this is very helpful

138:41

because sometimes we may need to add

138:44

children so if we have

138:46

a

138:47

an object that has several objects

138:49

inside of it and we want them all to

138:52

move in unison instead of coating all of

138:55

the children we can simply code things

138:58

to the parent and the children will move

139:00

with the

139:02

parents so

139:04

we'll be using a lot of

139:06

uh parent children relationship will be

139:09

using prefab also a lot and now it is

139:13

time for your challenge and your

139:17

challenge is to create a new prefab so

139:20

create a new object in our scene

139:23

whichever scene you want

139:25

prefab it

139:27

make an instance of it in a different

139:29

scene

139:30

and add a component to that instance

139:33

apply the changes to prefab and see what

139:36

happens and if you want as an extra

139:38

challenge you can also make a child

139:41

parent

139:42

relationship somewhere in our scenes so

139:45

pause the video right now and go do the

139:48

challenge

139:50

okay welcome back how did you get on

139:53

with that i hope it wasn't too hard so

139:56

let's take this cube put it over here

139:59

our magic cube which is a square

140:02

ironically

140:03

and now let's go and go ahead and create

140:06

something so we'll go into sprites let's

140:09

see we'll create a

140:12

diamond because diamonds are forever so

140:15

diamond

140:16

click on enter and let's go ahead and

140:20

put it in our scene

140:22

and we'll

140:24

put it inside of sprites so now we have

140:26

a diamond let's make this diamond a bit

140:28

bigger and let's change its color

140:32

so let's make it a blue because diamonds

140:34

are kind of blue i guess

140:37

so now we have this diamond in here

140:40

and what we want to do is we want to

140:43

so what was our challenge it was make an

140:46

instance in a different scene

140:48

and add a component to the instance okay

140:51

so we take this diamond and let's prefab

140:54

it and now because we have two prefabs

140:57

let's create a folder

140:59

call this prefabs and everything is

141:02

organized and neat

141:04

so now we have the diamond let's go

141:07

ahead

141:08

save that

141:09

go back into our level one scene and we

141:13

have three cubes here but no diamond but

141:16

we can easily add one from our hierarchy

141:20

super easily

141:21

so let's add a components component

141:24

let's add a rigidbody

141:27

2d

141:29

and let's also add a

141:32

collider and what kind of collider

141:35

should we add to it

141:37

let's go ahead and add a

141:40

circle yeah sure why not a circle well

141:43

actually it should be a polygon collider

141:45

let's make it a polygon collider and it

141:49

fits perfectly

141:50

and actually just for the fun of it

141:52

let's go ahead and rotate it in the y

141:56

direction

141:58

nope not in the y direction i meant in

142:00

the z direction

142:02

okay great so save that

142:05

but right now we are clicked as you can

142:07

see we have we are clicked on the

142:10

diamond in our scene and we've actually

142:12

added a rigid body and a polygon

142:15

collider so

142:17

it's not added to our prefab if we click

142:20

back on our prefab in projects here

142:22

below

142:23

we can see that it doesn't have any

142:26

rigid body or

142:28

collider so back into diamonds

142:31

click on override apply and now in our

142:36

second level save that in our level two

142:40

wait sorry for that

142:42

scenes level two the diamond

142:45

actually has rigid body and a polygon

142:48

collider which is great so click on play

142:51

just to see it fall

142:54

our diamond falls

142:56

and everything falls and as you can see

142:58

the

142:59

even even

143:00

the circle falls with our cube but

143:02

because it doesn't have a collider nor

143:04

does it does it have a rigid body but it

143:07

moves with our cue so

143:10

i hope you did the challenge i hope you

143:12

enjoyed this video and i think this will

143:15

be the last video in our section in the

143:17

next section we are going to actually

143:19

start creating our game so exciting so

143:23

review this

143:24

make sure you understand everything in

143:26

this section and don't forget to

143:29

always commit our work so

143:32

let's commit this

143:34

stage all

143:37

added a diamond

143:40

prefab and

143:44

added

143:45

a child circle

143:48

to my

143:50

magic cube

143:51

okay great so commit that

143:55

it's saved we have it in our

143:57

comments right here and i'll see you in

144:00

the next video

144:04

hey

144:05

you are almost 50

144:08

the way with the course how cool is that

144:11

you know that you are one of the fair

144:13

few i

144:15

think

144:16

less than

144:17

20

144:18

make it 50

144:20

of the way down the course so

144:22

congratulations i hope you're having fun

144:25

i hope you're enjoying your time let's

144:28

not waste any more time and let's get

144:30

started

144:36

[Music]

144:42

and welcome back my favorite game

144:44

developers in this video i'm going to

144:47

talk a bit about

144:49

game design and as you can see i've

144:51

already started and already the google

144:54

slides are very excited to tell tell you

144:57

about the game sketch so

145:00

the game sketch is the following

145:02

now

145:03

it's not very impressive but it will get

145:06

the concept of our game around so you've

145:09

already watched the introduction video

145:11

where i've showed you the game that we

145:14

have finished already but now i will

145:16

take you through the steps that it took

145:19

for me to get the game

145:21

developed so first thing first i've

145:24

created this mini sketch and as you can

145:26

see

145:27

well it's not very impressive but it

145:29

gets the job done so first thing first

145:31

we have the tiles right here which will

145:34

define our world

145:36

and we have the background tiles or the

145:39

world confiners right here on both sides

145:43

next thing we have are the doors so

145:46

we'll have the enter door through which

145:48

our conqueror right here this little guy

145:51

can enter through and start the level

145:53

and this is the door right here that he

145:56

has to go through in order to advance to

145:58

the next level or room

146:01

next thing we have the bombs right here

146:03

that

146:04

i've sketched as burning

146:06

and they will explode as soon as we get

146:10

near them well not as soon as they will

146:12

start burning when we get near them and

146:14

they will explode eventually

146:16

we have the hearts that we can pick up

146:19

in order to increase the lives we have

146:21

we have of course the hanging sheets

146:24

right here that we can climb to get to

146:26

platforms that are unreachable

146:29

we have the diamonds of course that we

146:31

pick up to increase our score and we

146:34

have the little monsters right here that

146:36

will try to attack us and kill us but we

146:38

have the power of thor's hammer that

146:41

will crush any enemy in our path

146:44

and also we have this little square

146:46

right here and if you've noticed in the

146:48

introduction of course you've noticed

146:50

because i've told you like 10 times

146:52

become because i'm so proud of it this

146:55

is

146:56

the camera that will follow our player

146:59

wherever he goes so instead of having a

147:02

huge camera around the entire level and

147:05

having to move our tiny tiny player

147:08

around we make the camera follow our

147:10

player wherever he goes

147:13

that is very cool and i encourage you to

147:16

create your own game sketch and see how

147:19

you want to make your own game

147:21

so next thing let's talk about the 2d

147:24

platformers because our game is going to

147:27

be a 2d platformers

147:29

so i'm sure you're familiar with a

147:31

couple of these this is a recent game

147:33

called celeste which

147:35

many regard as one of the best games of

147:38

i think 2000 2017 i'm not sure but it's

147:42

a fairly modern game and as you can see

147:45

it's just like our game where it has

147:47

styles and it has a

147:50

pixelated character that moves around in

147:53

the

147:54

2d platform that they have created

147:57

next thing we have a hollow knight not

148:00

sure if you've played this game but it's

148:02

really amazing it's

148:05

similar to dark souls and it's

148:07

difficulty but it's a 2d platformer and

148:10

i've used modern uh examples just to

148:13

show you how much 2d platformers are

148:16

still

148:17

relevant in game development and you can

148:20

see right here that it also has a tile

148:23

maps and platforms and backgrounds and

148:26

little pixelated

148:27

although they are better more polished

148:29

than our game and not as pixelated but

148:33

the same concept applies

148:35

and finally we have shovel knight i'm

148:38

not sure if you've played shovel knight

148:39

but it is an amazing game i've played it

148:43

i finished it it's very cool and as you

148:46

can see this is very similar to our game

148:49

it has the ladders it has the enemies

148:52

while the enemies are bigger and it's

148:54

pixelated just like our game and the

148:57

final example i found this on google i'm

149:00

not sure who did it but as you can see

149:02

they have

149:05

sketched up the game and the pixelated

149:08

it and it shows the tiles that were used

149:11

to create the game we will use similar

149:14

tiles or similar

149:16

way of

149:18

tiling our game and making our game

149:21

a 2d platform just like this one with

149:25

ladders with platforms and with a

149:27

background

149:29

so castle conquest game design what am i

149:33

going to talk about right here so this

149:36

is a screenshot of our game and let's

149:38

talk about the core mechanics so we'll

149:41

have our conqueror running jumping

149:44

climbing and he will also be attacking

149:48

what else should we talk about

149:50

the core gameplay well it's going to be

149:53

getting from the start of the level from

149:56

the starting door to the end without

149:59

getting hit more than three times as you

150:02

can see uh as you saw in the

150:04

introduction video i've showed you that

150:06

our player

150:08

uh or the conqueror is the player in our

150:11

game has only three lives and uh that's

150:15

uh not talking about the lives that he

150:17

can actually pick up but every time he

150:19

gets hit he loses a life and if you lose

150:22

three lives you're done you need to go

150:24

back to the main menu

150:27

so let's talk about game story also

150:29

because that is you might think that

150:32

well you know what i don't think we need

150:34

the game story and you are completely

150:37

wrong because the game story is

150:40

well the game story will be the

150:42

i'm not going to say the core but it is

150:45

the nucleus around which the core is

150:47

built

150:48

so what is our game story well you are a

150:51

king and you've just inherited the

150:54

castle from your father monsters pigs

150:57

have taken it and you need to defeat

150:59

them all and you need to go through

151:01

every room and try to crush every single

151:04

one of them and also along the way

151:07

you'll need to collect the diamonds so

151:10

this will make the game much more

151:12

interesting and as you're playing

151:14

through it you can feel that you have

151:17

the

151:18

ability to take charge of whatever is

151:20

happening in the game and you have a

151:22

reason for killing the little pigs not

151:24

just for the sake of killing them you

151:26

have a reason and you're collecting

151:28

diamonds for a reason because your

151:30

castle is infested with them and you

151:33

need to take back your pride

151:35

okay that's a bit dramatic but you get

151:38

the point you always need a story for

151:40

your game next thing we're going to talk

151:43

about are the technical requirements to

151:46

create this game so

151:48

as you can see we had a lot of stuff so

151:50

first thing we need is a tile set for

151:52

the background and the foreground with

151:54

some elements so

151:56

i've chosen a tile set that i will show

152:00

you later on where i got it from

152:03

and i will leave it of course in the

152:04

resources

152:06

feel free to go and get your own tile

152:08

sets but make sure that you have a

152:10

foreground and a background tileset for

152:13

our game

152:14

next thing we're going to use inputs

152:17

from the keyboard to control our game

152:22

we will add a follow cam that will

152:24

follow the player or the conqueror

152:26

wherever he goes and zoom in and out

152:29

depending on his movement as you saw in

152:31

the introduction video when we're

152:33

running there is a certain zoom in when

152:36

we're standing still or idling there is

152:38

a certain

152:40

zoom out and so on and so forth and will

152:44

also create an automatic way of adding

152:47

background to our game that means that

152:50

we'll add a rule will add rules to our

152:53

tiling and make all the background

152:56

automatically fill everything and save

152:58

us a lot of time

153:01

so

153:02

let's talk about some more gameplay

153:04

features that we'll have

153:06

as you can see right here our

153:09

little player is punching the air but

153:11

even though the pig is a bit far away

153:14

but the conquerors movement we've

153:17

covered this before but it's going to be

153:18

running jumping and swinging the hammer

153:21

as you can see right here depicted in

153:23

our screenshot

153:25

there will be hazards there will be

153:27

bombs that will that

153:29

bombs that burn and explode if we're

153:32

near and they can actually kill us

153:35

we will have a start and end point we'll

153:38

have doors

153:39

that the conqueror walks through to get

153:42

from one room to the next and by room i

153:45

mean the levels of our king

153:47

next thing we'll have the pickups and

153:49

the pickups are lives along the way for

153:52

the player to pick up as we walk and all

153:55

the diamonds that you can carry with you

153:58

now it's time for your challenge and

154:01

your challenge is going to be to create

154:04

your own

154:05

game design

154:06

so

154:07

figure out a story for our game think of

154:11

a compelling story a story that will

154:13

make but whoever is sitting behind the

154:16

computer and who's going to play your

154:18

game feel excited and give him reason

154:21

give him reason give him

154:24

the motivation to go up and kill all the

154:27

pigs and collect all the diamonds next

154:30

thing you need to find find out the game

154:33

mechanics you want maybe you want to add

154:35

other game mechanics and i completely

154:37

encourage you even if you don't know how

154:40

to actually implement those mechanics

154:43

just write them down keep them with you

154:46

and along the way you will find out how

154:48

to create them

154:50

you will go and download your own

154:53

sprites and tile set

154:55

and as i've told you make sure that you

154:56

have the foreground and the background i

154:59

will leave the links in the resources

155:01

for you to go ahead and download or

155:04

search for whatever tile sets and

155:06

sprites you want or you can simply use

155:09

the same that i'm using

155:11

figure out what features you want to add

155:13

so as i've told you we have picking up

155:16

things we have climbing the sheets you

155:19

can also add your own features i'm not

155:21

sure what that those will be but for

155:23

example you can add power ups that's a

155:26

good idea so write that down also and

155:30

figure that out for yourself and

155:33

as i've told you this is going to be

155:35

very exciting i'm so pumped to start

155:38

creating this this game and i hope so

155:40

are you so let's start our journey

155:43

together and i'll see you in the next

155:46

video

155:52

[Music]

155:58

welcome back everyone now we are

156:01

starting a new

156:03

project which is very very very exciting

156:07

okay so first thing we are going to

156:10

create our project so open up your unity

156:13

hub and go into add new so it will be a

156:17

2d project and we'll name this

156:21

castle

156:24

conquest

156:26

to

156:27

d and remember where we're saving it

156:29

because we'll need it for the

156:31

repo to create

156:34

and now we wait for the project to be

156:36

created i'll see you in a bit

156:40

welcome back so

156:42

i've accelerated the process of creating

156:45

the unity project using the magic of

156:48

editing

156:49

and now we will go we are going to set

156:52

up a new repo so this is from magic cube

156:55

to set up a new repo simply click on the

156:58

plus button up there you can close this

157:00

tab

157:01

and click on the create button right

157:04

here so we browse for our path

157:07

so wherever you've saved your path go

157:10

into that and click on the castle

157:13

conquest 2d

157:15

select the folder keep it on good keep

157:17

the create repository on account

157:19

unchecked for now

157:21

click on create

157:23

click on yes and now we have a repo so

157:27

as always

157:28

we know that we should simply

157:30

click on the library ignore everything

157:34

ignore everything beneath library

157:36

click on ok

157:39

now we go into the get ignore double

157:42

click

157:43

open in our notepad

157:45

and you should have everything

157:48

by copying it and pasting if you don't

157:50

remember how we did it check out the

157:54

i don't not sure which video i think

157:56

it's the second video in the previous

157:58

section and you'll find where you can

158:00

get the git ignore

158:01

or simply google it and now we have

158:03

everything set up so we simply going to

158:07

stage all

158:09

commit

158:10

and call this

158:11

initial

158:14

commit

158:16

click on commit and we are ready to go

158:20

so

158:21

first thing we're going to do is we're

158:23

going to be importing the sprites i've

158:25

provided you in the resources so go

158:28

ahead and get them

158:31

simply click on them and drag them into

158:34

our

158:34

project right here now before we get

158:37

started i want to take a moment and

158:40

explain what

158:41

is a sprite so

158:44

this is a sprite this will be a our hero

158:48

or our conqueror

158:50

and as you can see he is a image so a

158:53

sprite is a 2d object and this 2d object

158:58

has a graphical image

159:01

on it called texture so sprites are 2d

159:05

objects and they have graphical images

159:07

on them called textures

159:11

and they are used by adding a component

159:14

called sprite renderer to an empty game

159:18

object so we create a game object we add

159:22

a sprite to it and we can

159:24

have a graphical image

159:27

on it

159:29

okay

159:29

so

159:30

now that we've explained what a sprite

159:33

is

159:35

it's

159:36

time for us to create our terrain so

159:41

our or before even that it's time for us

159:44

to slice up our terrain so right now

159:47

if you click on this small arrow right

159:49

here you can see that it's a single

159:52

image

159:52

so what we need to do is we need to

159:55

slice it up so if we click on it you can

159:58

see here in the inspector that we have

160:00

many options and one of them is the

160:02

sprite mode first thing you need to make

160:05

sure that your texture type is of sprite

160:07

2d and ui and the sprite mode should be

160:11

multiple

160:13

so

160:14

click on that

160:15

and apply everything and go into sprite

160:18

editor so as you can see here we have

160:20

all of these

160:22

so the top ones will be our foreground

160:25

and the bottom ones will be our

160:28

background

160:29

so here on the top on at the left you

160:31

can see that we have multiple ways of

160:34

slicing our sprites one of them is

160:37

automatic so let's try that as an

160:39

experiment so if we click on slice

160:42

we can see that it slices them up pretty

160:44

good but that is not what we need we

160:47

don't want this entire block to be a

160:50

single slice we want to slice it up into

160:53

four little sprites and this one also i

160:56

think this more than i think this one is

160:59

nine surprise this one is for little

161:01

sprites so how can we do that well

161:04

actually in slice we have something

161:07

that's called grit by cell size or grid

161:10

by cell count we'll be using the grid by

161:13

cell size

161:14

and i know that it should the pixel size

161:17

should be 32

161:19

by 32

161:21

so we slice that up click on slice and

161:25

now we have our sprite sheet sliced up

161:29

into little sprites

161:32

okay great and you can click on each one

161:35

of them and check the information about

161:37

it so this is terrain

161:39

this is terrain also and each of them

161:42

has a number now if you have the time

161:44

and you want to be very meticulous with

161:47

this process you can actually rename

161:49

each one of them and make it your own

161:52

but we don't need that honestly

161:55

okay great so apply that in on this

161:58

button right here apply that

162:01

and now we

162:03

have our sheets sliced up

162:06

excellent

162:07

great

162:08

and this is everything we'll need to do

162:11

and it's time for a challenge and your

162:13

challenge is going to simply be slice up

162:16

your own sprite sheet so import whatever

162:19

sprite you choose to use for your game

162:22

i've given you the resources the website

162:25

where you can find

162:26

free

162:27

game arts

162:29

and

162:30

simply import them slice them up

162:33

into sprite sheets for the background

162:35

and the foreground tiles make sure that

162:38

you have background and foreground

162:41

and

162:42

as a last

162:44

step of this process we are simply going

162:46

to create a folder

162:49

we'll call this sprites

162:52

and we'll drag the terrain inside of it

162:55

and another thing maybe we'll change

162:57

this and name this

163:00

level

163:02

zero because we don't have any other

163:04

level simply level

163:06

zero okay so this project will be great

163:10

it will have lots of sprites it will

163:12

have lots of scripts so let's start with

163:16

some good organization habit for the

163:18

first

163:19

video and i'll see you in the next one

163:22

[Music]

163:28

welcome back everyone to another amazing

163:30

video and this especially is the best

163:34

video i think in the whole course

163:37

because we are actually creating our

163:39

platform as you can see here we've made

163:42

a small platform we have the style map

163:45

over here on the right we have on the

163:47

left also a tile map grid in our

163:49

hierarchy we've used all the sprites

163:52

that we've sliced before to create this

163:55

platform right here so let's not waste

163:58

any time i'm so excited for this video i

164:01

hope you are too so i want you to summon

164:05

all your creative power to this video

164:08

and i'll see you in a bit

164:11

okay so tile maps what are we going to

164:14

do

164:15

well first thing we did is we got our

164:18

sprite sheets

164:20

we sliced them up into little sprite

164:23

sheets

164:24

we are going next to create tile assets

164:28

we are going to take those style assets

164:31

and add them into our tile palette and

164:34

finally we'll use our tile palettes to

164:37

create our tile

164:39

map

164:40

okay great so back to unity

164:44

where we are going to

164:47

first of all go to window and look for

164:50

our tile palette which should be under

164:54

2d

164:55

and style palette so click on that and

164:58

now we have our tile palette feel free

165:01

to dock it wherever you want i feel like

165:04

i want to dock next to the inspector

165:07

make this a little bit bigger because we

165:09

are going to need it needed later on

165:12

next step we go into our hierarchy here

165:15

on the left where we don't have anything

165:17

except for main camera so right click

165:21

and go to 2d object and look for tile

165:25

map when you click on it we can see that

165:28

a grid has been created it's called the

165:30

grid in our hierarchy and a tile map so

165:35

let's change the name of the style map

165:37

to

165:39

let's go into inspector make sure you go

165:41

from inspector to tile map so tile map

165:44

changes to

165:45

background

165:47

and

165:48

create another one

165:50

so in grid we're going to create another

165:53

tile map and we'll call this one

165:56

foreground okay great and we'll also

166:01

rename this from grid to

166:03

tile

166:05

map grid

166:07

everything is great so

166:09

now what we're going to do

166:11

is we're going to

166:13

create a new tile palette

166:16

so go into tile palette and here under

166:18

create new tile palette click on it

166:22

and it will ask you for a name

166:25

we'll simply name this

166:27

main

166:29

wait main palette

166:32

create

166:33

and it will ask you where you want to

166:34

save it it's

166:36

these are your assets folders so let's

166:39

go ahead and create a new folder called

166:42

the styles

166:44

and save it inside of our tiles select

166:47

the folder now we have a new folder

166:49

which styles and it has a main tile

166:52

palette and this is our tile palette so

166:56

what are we going to do now

166:58

go back into our sprites in the

167:02

hierarchy on the left

167:04

and choose all of these sprites so

167:09

go ahead and choose all of them to do

167:12

that more fast click on the first one go

167:15

to the last one hold shift and click on

167:18

it so you choose everything

167:20

and drag them into our tile palette and

167:23

we should have a big huge mess right now

167:27

go back to tiles

167:28

and inside of tiles select the folder

167:32

and save them there so

167:34

wait for them to become tile assets

167:38

and they should be

167:40

now

167:41

okay so as you can see a huge mess has

167:45

been made now of course we are going to

167:48

be moving all of these and rearranging

167:52

them now you can rearrange them the way

167:54

you want to

167:56

i will do it later on

167:58

i will it will be the same arrangement

168:00

as the one on

168:02

the terrain feel free to do your own

168:05

arrangement so

168:06

now it's time for the exciting part so

168:09

let's choose one of these styles and

168:11

start drawing

168:13

but as you can see

168:16

these are very small so what's the

168:19

problem the problem is that when we are

168:22

choosing our sprites they are actually

168:26

the pixels per unit is 100 so how are we

168:30

going to make them fit

168:32

we're going to change this to 32. so go

168:35

to our sprite click on it go to the

168:38

inspector and make sure that the pixel

168:40

per unit is 32

168:42

apply that and they fit perfectly into

168:46

our squares

168:47

great

168:49

back to our tile palette and now

168:52

let's go ahead and draw a simple very

168:55

very simple

168:57

background so we can also let's learn a

169:00

bit about the stuff up here so every

169:03

time you want to draw you have to make

169:05

sure on which active tile map you are so

169:08

for example i just drew a ti a bit of

169:11

tires which were on the background which

169:13

was not correct you need to make sure

169:16

you choose the right active tile map

169:19

and

169:20

over that you can see that we have this

169:22

brush with which allows us to draw a

169:24

single

169:26

tile every time

169:28

we have next to it this

169:30

box drawing which we can simply click on

169:32

here and drag it and make as many boxes

169:35

as we'd like we have this

169:38

pick where we choose one of this these

169:40

and we can actually change all of them

169:43

and

169:45

now you can also experiment with all of

169:48

this and we finally have this

169:51

uh what is what is this a an eraser

169:54

which where we can remove whatever we

169:57

feel like removing

169:59

so let's draw this again

170:01

and now we are going to change into

170:04

foreground

170:06

and now when we are foreground we choose

170:08

the tiles for the foreground

170:11

back to

170:13

background make sure that we

170:17

everything is in the background and the

170:20

things in foreground are always the

170:23

tiles for foreground so now if we click

170:26

on play

170:28

this will be our game view how cool is

170:31

that we're beginning to create our game

170:35

excellent

170:36

but

170:37

something i want to point out is that

170:40

we need to make sure that we are working

170:42

on the right layers so what do i mean by

170:46

that well

170:47

if we go back into scene and our tile

170:49

palettes if we click on the background

170:52

we can actually draw over our foreground

170:55

palette tiles which is not very good we

170:58

need to make sure that whenever we draw

171:01

our foreground is well in the foreground

171:05

so how do we do that we do that using

171:08

sorting layers and sorting layers are

171:11

very very cool aspect so if you go into

171:15

the hierarchy in background you can see

171:17

that we have a tile map

171:19

under it we have a tile map renderer now

171:23

if you want to go into the unit

171:25

documentation and find out everything

171:27

about everything

171:29

feel free to do that but what we're

171:31

going to focus on are these additional

171:33

settings so if you have it closed open

171:36

it up

171:36

and you can see that we have sorting

171:38

layers and we have order layers

171:41

and now on foreground you can see that

171:44

we have these sorting layer and order

171:47

layer

171:48

so we need to create a sorting layer for

171:52

our background so click on the sorting

171:55

layer which is now default and click on

171:57

add sorting layer

171:59

so to add a sorting layer simply click

172:02

on this plus right here

172:05

and we'll call this our

172:08

for

172:09

ground

172:10

let's add another sorting layer and make

172:13

this one

172:14

back

172:15

ground

172:16

now we have two sorting layers and below

172:20

it and above it we can see the tags

172:22

which is something that's useful for

172:24

coding and

172:26

layers below it which is good for

172:28

collisions we'll talk about these later

172:31

on so go back into foreground

172:34

and now in the sorting layer instead of

172:36

default choose foreground

172:39

and for the background choose

172:42

background but as you can see here our

172:45

background still is in front of our

172:47

foreground why is that well if we go

172:50

back into

172:51

the layers to the sorting layers the

172:54

ones below will be rendered first

172:58

so if we move up the background and put

173:01

it above the foreground the foreground

173:03

will be rendered in front of

173:06

the background and every time you need

173:09

to make sure that you have your layers

173:11

in the right

173:13

ascension or the sanction

173:15

okay

173:17

excellent save that and now we are going

173:20

to create a simple

173:22

platform

173:24

a very simple platform but first no not

173:27

challenge not yet first i will use the

173:30

magic of editing to

173:32

rearrange all of these styles in here

173:35

and it's not going to be something very

173:37

amazing you can do it the way you wish

173:39

to do it i'll simply make it the same as

173:42

our original arrangement okay i'm back

173:46

from my magical editing trip

173:50

so as you can see i've rearranged all of

173:52

my tiles and i forgot to do something i

173:56

forgot to teach you how to actually do

173:58

that so excuse me to do that simply

174:01

click here on edit when you click it you

174:03

actually have access to all of these

174:06

tiles so

174:08

if you check on here you can actually

174:10

select an area of the grid using s and

174:12

then you can move it using m so click on

174:16

s click on one of the tiles

174:18

click on m and now you can move it

174:21

wherever you want and when you finish

174:24

editing simply click on this edit button

174:27

and it will save for you so let's change

174:30

this back s

174:32

and m and save and ctrl s to save

174:35

everything

174:36

and now

174:38

it's time for your

174:41

challenge and your challenge is going to

174:43

be to be to create your own platform so

174:47

create the foreground and background

174:49

tiles

174:51

create a new tile palette

174:53

rearrange the tiles in that palette just

174:56

as i did or find your own personal way

174:59

of rearranging them

175:01

create a platform from the foreground

175:04

with a background so

175:07

pause the video right now rearrange the

175:09

tiles the way you want them to be

175:11

rearranged and then

175:13

go ahead and create some kind of

175:16

platform don't worry about how much the

175:19

platform should be amazing or great this

175:23

is just for simple training i'll do it

175:26

later on but pause the video right now

175:28

and try your best okay how did you get

175:32

on with that i am so excited to see what

175:35

your palette would look like

175:38

so now i am going to create a small tile

175:42

just inside of our screen so if we dock

175:45

the game right next to it and it's 16.9

175:48

great so we can see it but for now let's

175:52

simply keep it there

175:54

and i'm going to create a platform just

175:56

inside this camera and to not bore you

175:58

with all the details i'm going to

176:01

again use the magic of editing it's such

176:04

a good magic

176:06

it's better than harry potter's magic

176:08

and i'm going to

176:09

create a

176:11

grid or map right here so i'll see you

176:14

in a bit

176:49

hello and welcome back so as you can see

176:53

i've created

176:54

a small platform right here and what

176:57

this platform consists of is

177:00

just

177:01

i made a small or not small a rather big

177:05

wall in here an obstacle

177:08

maybe i'll make it smaller later on i

177:10

made a little platform here where we

177:12

might we might put i don't know maybe

177:15

diamonds or a hidden box then i made

177:18

these kind of steps where our player can

177:22

jump on and that's basically it nothing

177:25

too fancy

177:26

and i hope you did create your own

177:30

platform or you might have waited for me

177:33

to create the platform and then took

177:35

inspiration from it

177:36

but what i want you to do is create your

177:39

own platform don't just copy mine

177:41

because this is the best part in the

177:43

course it's actually creating levels

177:46

using the amazing magic of

177:49

tile maps a lot of magic in this video

177:52

and i'll see you in the next one

178:02

[Music]

178:07

welcome back everyone to a brand new

178:11

video and this video we are going to be

178:13

investing time

178:15

yes we'll be investing time right now to

178:18

save ourselves a lot of time later and

178:21

we'll do that by creating rules for our

178:24

tiles so as you can see and now we can

178:28

sim

178:28

automatically

178:30

create tiles so as you can see they fill

178:33

up automatically which is very cool and

178:36

very helpful

178:37

so

178:38

i'll be teaching you how to create these

178:41

rules i'll give you all the resources

178:43

needed it will take some time and some

178:46

understand some understanding to get it

178:48

but don't worry about it everything will

178:50

be explained so

178:52

i'll see you in a bit

178:54

okay so first thing we're going to do is

178:57

we're going to be importing our 2d

179:00

extras tile map rules

179:03

there are two ways to go about this you

179:05

can either go into a google and type 2d

179:09

extras unity and then go into your into

179:12

the first

179:14

result which is github and download

179:16

download it from here

179:18

you'll get a zip folder and you simply

179:21

have to import it

179:22

first of all extract it and then you

179:24

simply drag it into your

179:27

unity assets or you can use the one i've

179:29

provided you in the resources i will use

179:33

that right now so simply take this rule

179:36

tile that i've provided drag it into

179:38

unity and put it inside of assets

179:41

wait for it to import it will give you a

179:43

long list of things to import simply

179:45

click on import right here on the bottom

179:49

right corner

179:51

wait for it to finish up and now

179:54

you should have this folder right here

179:56

when you do get this folder you can go

179:58

into tiles

180:00

and you can simply

180:03

let's go ahead and

180:06

put all of these in a

180:08

single folder let's go ahead and call

180:10

this

180:14

terrain terrain

180:17

tiles

180:18

go ahead choose all of these

180:21

and simply drag them into terrain tiles

180:23

to have

180:24

more space and now if you right click

180:27

on your

180:28

whatever you where you want i recommend

180:31

you go into tiles go into create and you

180:34

can find at the top right here that you

180:35

have something new one one is a prefab

180:39

brush and the other is rule title so

180:42

click on rule time

180:43

and and for this particular rule set we

180:46

are going to

180:48

make rules for our background so let's

180:51

go ahead and call this

180:53

background

180:55

rule

180:57

tiling

180:59

and now if we click on it and go into

181:01

the inspector you can see here that we

181:03

have

181:04

some weird structure of

181:07

windows so

181:08

we have the default sprite and we have

181:11

the tile rules a list which is empty and

181:14

we can add this list by clicking this

181:16

plus button right here and we can add

181:19

rules

181:20

first thing you need to do

181:22

is dock this inspector so simply go up

181:26

to the upper right of your screen and

181:29

click on this little lock here and now

181:31

this will not change this will be very

181:34

helpful

181:35

so now as you can see it tells us that

181:37

there are none

181:39

sprite

181:40

so we need to add a default sprite and

181:43

because we are working on the background

181:45

we'll be only working on the background

181:47

sprites

181:48

so go ahead and add whatever random

181:51

sprite you want to be the default and

181:54

now we are going to start and

181:56

by creating our tiling rules so the

181:59

first rule will be for a tile

182:03

which should be in the middle just like

182:06

this one which doesn't doesn't have any

182:08

sides to it or neither does it have any

182:11

little

182:12

i'm not sure what those are what those

182:14

are called these are for the corners by

182:17

the way and this will become all clear

182:19

just in a bit

182:21

so now we've created our first rule

182:23

congratulations

182:25

let's go ahead and add it to our tile

182:28

palette so you can either create a new

182:31

tile palette simply

182:32

just for our rules or you can add it

182:35

right here up there

182:37

above all the default tiles i'll add it

182:40

into this one

182:42

because it's more practical i believe so

182:44

simply click on this background and drag

182:46

it into our tile palette and should it

182:49

should show right here so now if we

182:51

click on this one

182:53

we can actually draw

182:55

these rule

182:56

tiles see that okay great and as you can

183:00

see the all of them are of the same type

183:04

but if we choose to

183:06

create rules for it so for example if we

183:09

click on this one as you can see

183:11

everything changes

183:12

why is that well let me explain these

183:15

how these rules actually work so

183:18

let's see this three by three box right

183:21

here and if we add we can actually add

183:25

these kind of arrows and as you can see

183:28

the more we add the more it changes and

183:30

what these mean is the green arrow means

183:33

that there is a tile above it so when

183:36

there is style above it to the left of

183:39

it to the right of it and below it then

183:42

we can draw this tile so this is a rule

183:46

and if we click on this green arrow

183:49

again

183:50

we can see that it becomes an

183:52

a red x and what this red x means that

183:56

it will only draw when there is nothing

183:59

to its right and we can see here

184:02

oh and if we actually click here it

184:05

actually

184:06

makes

184:07

well it shows us what will happen if we

184:09

add a tile here

184:11

and you might be wondering why are all

184:13

the other tiles this way well because

184:15

it's our default sprite so let's go

184:18

ahead and add another

184:20

rule and let's keep this like this

184:23

because

184:24

actually this is our rule for this

184:26

particular tile so let's go ahead and

184:28

add another rule and for this rule let's

184:31

go back into sprites

184:33

we'll add a

184:34

corner on the right side so let's go

184:37

ahead so what do you think the right

184:40

side should have as its rules well i

184:43

think it should have

184:45

one below it one to its right and one on

184:49

its diagonal and it shouldn't have

184:51

anything

184:52

on either side

184:54

now nothing changed pretty much but

184:56

that's okay because we'll add another

184:59

rule

185:00

and for this rule let's see what we have

185:02

let's add this one

185:04

oh

185:05

and in this case if we have something to

185:10

on these sides and nothing on that side

185:14

we should have

185:15

this

185:16

right here and it's

185:18

pretty much correct now

185:20

so let's go ahead create another rule

185:23

and add this one to it

185:26

so now if we have for example what

185:30

should this have if it doesn't have

185:32

anything to its right

185:34

and it has something on its left it

185:38

should create this one

185:40

another thing about these rules right

185:42

here is that you can actually change

185:45

them and they can be either rotated or

185:48

mirrored on the x or y axis

185:51

what does that mean well if we click on

185:53

this one you can see that

185:56

it rotates all the rules so it

186:00

if we don't want to create rules

186:02

for for example we want to make a rule

186:05

that's like this one

186:07

okay we can simply click on the mirror

186:09

mirrored on the

186:11

uh

186:13

axis and it will create that rule for us

186:17

but we won't be needing that because our

186:20

assets are rich and they have everything

186:23

in them

186:24

so

186:25

now

186:27

i'm going to create

186:29

a set of rules let's simply delete that

186:31

one because we don't need it i'm going

186:33

to create a set of rules and before i do

186:36

that i'm going to issue you a challenge

186:39

and your challenge is going to set up

186:41

your own rules

186:42

because

186:43

maybe i believe even that you can create

186:46

better rules than me for the background

186:48

so first thing is import it to the

186:51

extras file i've provided in the

186:53

resources

186:54

then you have to set up your rules for

186:56

automatic tiling

186:58

and use the rules to paint your own

187:00

platform so

187:02

go ahead and try your best and if you

187:05

feel that you can't even come up with

187:07

these simplest rules

187:09

i have provided in the resources also

187:12

the rules i've screenshotted everything

187:14

beforehand so

187:17

i'll see you in a bit

187:20

okay

187:20

welcome back so how did you get on with

187:23

that i hope you at least tried to create

187:26

some rules

187:27

so let's show you let me show you what

187:30

i've done

187:31

so i have created i think it's about 17

187:34

rules

187:35

and the way i did them i actually

187:37

started looking at different ways that

187:40

each style might work and how it should

187:43

be positioned

187:45

and of course if you don't have any idea

187:48

how to create the rules i've provided

187:50

you some pictures and or screenshots

187:53

that i've made so you can

187:56

copy them and use my tiles but remember

188:00

mine are not perfect by any means and i

188:03

left out a lot of tiles because it's a

188:06

very exhaustive list i want to create an

188:08

example for you to create your own rules

188:12

it will not be easy it will not be done

188:15

in

188:16

10 minutes i think this actually took me

188:20

i think about two maybe two and a half

188:23

hours to finish all of them and test

188:25

them and make sure all of them work so

188:28

to demonstrate how the automatic tiling

188:31

works let's go ahead and choose to erase

188:33

a couple of them so as you can see when

188:36

we erase them

188:38

new tiles are created to wrap around and

188:41

as you can see we have a mistake right

188:43

here

188:44

and there there might be a lot of other

188:47

mistakes but some of them work like this

188:49

one for example works perfectly fine so

188:52

let's go ahead and delete all of these

188:56

and delete all of these

188:59

and let's try them out in our platform

189:01

and see how they work so let's go ahead

189:04

and click on this choose the automatic

189:06

tiles

189:08

and let's remember to always have it on

189:11

background so let's create

189:13

something right here and then we'll

189:16

create something right here and as you

189:18

can see they fill up automatically

189:22

and it's

189:23

perfect i guess let's see if

189:26

oh there is something right here i think

189:29

we need to create another rule for that

189:32

i believe it's the one where you have

189:36

only two on each side so

189:39

let's see

189:42

okay so let's go ahead and create a new

189:46

rule and let's see which one we should

189:48

use so we want to cover

189:50

we want to cover this area right here at

189:54

the top and one over here so we'll

189:57

choose which one which one okay this one

190:00

so let's drag it in here as you can see

190:02

it fills up automatically but that's not

190:05

what we want we want to actually create

190:06

a rule for it to always follow because

190:09

that will always default to this one

190:11

so it doesn't have a tile to its upper

190:15

left it doesn't have a tile to its

190:17

bottom right

190:19

and it has

190:20

tiles to

190:21

both sides and files to

190:24

above it and below it and on either side

190:27

excellent so now you can see that we

190:29

have our rule set up right here we can

190:32

automatically tile all the background it

190:34

makes our

190:36

platform much more aesthetic than having

190:38

all of them the same you can create also

190:43

a rule for your foreground tiles i tried

190:46

it it's meticulous it takes time

190:49

and i encourage you to try and create

190:52

that also it will make your life 20

190:55

times easier

190:56

i hope you enjoyed the video i hope

190:58

you're excited as i am about this in the

191:01

next video i think we'll be

191:03

finally adding our player or our

191:06

conqueror as we've called us will be

191:08

calling him our conqueror

191:10

so i'll see you in the next video

191:13

[Music]

191:18

welcome back my fellow game developers

191:21

as you can see we've created finally

191:24

we've created a

191:26

player and this player is our conqueror

191:29

we'll call him jimmy so

191:31

jimmy right now doesn't do anything but

191:33

if we click on play we can see that our

191:36

jimmy conqueror actually has an idling

191:39

animation that's running right here

191:41

below i'll

191:43

teach you everything that we've done

191:45

you'll have a big challenge so i want

191:47

you to give me your entire concentration

191:51

force and i'll see you in a bit

191:55

okay so

191:56

first thing we're going to do is we're

191:59

going to

192:00

unbox this

192:02

and we're going to delete all the

192:04

unnecessary things we have up here

192:07

so let's go ahead and delete all of that

192:10

zoom back in go to our inspector save

192:14

that

192:15

then

192:16

let's go and create an empty game object

192:20

and make this smaller we didn't don't

192:22

need it that big

192:24

click on that to remove

192:26

make it a little bit bigger and we'll

192:28

call this game object our player

192:31

and this player will be reset to

192:34

the middle of our screen

192:37

and honestly this is the most exciting

192:39

part of all game creation

192:42

when you start making your player

192:45

so

192:46

let's go over some technical words

192:51

animation 101

192:54

first first thing you need to learn is

192:56

an animator controller so an animator

192:59

controller allows you to arrange and

193:02

maintain a set of animation clips

193:05

you'll see what that is in a bit

193:08

an animator component used to assign

193:11

animation to an game object in your

193:13

scene so if you have a game object and

193:17

you wanted to have animations you assign

193:19

it an animator component and that

193:21

animator animator component gets an

193:24

animator controller it's a bit confusing

193:26

we'll see everything animations it's

193:29

several sprites rendered one after the

193:32

other so it's a set of sprites one after

193:35

the other we put them next just like

193:37

video works where it's a set of images

193:40

one after the other and finally a sprite

193:43

renderer we've talked about it

193:45

previously renders a sprite for 2d

193:48

graphics

193:49

okay great so back to unity

193:54

and from unity we are going to be

193:56

importing the sprites i've left you in

193:59

their resources for our human

194:02

so let's go ahead and go there and here

194:05

you can find that we have fall idle jump

194:07

and run so we'll use for now either

194:11

animation but in order to create the

194:14

other animations we have the run and

194:16

fall jump

194:17

so click on the idle and drag it into

194:20

our unity so we have it right here i'll

194:23

actually we don't want we want it inside

194:25

of sprites

194:27

so let's close that and now let's create

194:30

a folder

194:31

first for our

194:33

conqueror we'll call this conqueror

194:36

and our conqueror will

194:38

have this sprite first thing we're going

194:41

to do is we're going to be slicing up

194:44

our

194:45

conqueror

194:46

but before we do that i want you to

194:49

understand the steps that we are going

194:51

to take so

194:52

we are going to import the conquerors

194:55

sprite sheet and slice them up we are

194:57

going to create the player object we've

194:59

already done that and add a sprite

195:01

renderer to it we'll do that right now

195:04

we'll create will create an idle

195:06

animation

195:07

we'll add an animator to our player

195:10

we'll create a plan player animator in

195:14

order to add all the animations to it

195:17

we'll add an idle animation to the

195:19

animator and will assign the animator to

195:22

our player

195:23

so let's go ahead and do all of those

195:26

things

195:27

first thing let's slice up our player so

195:30

we'll go to multiple

195:32

we'll make the pixels per unit 32

195:35

and we'll apply all of that we'll go

195:38

into our sprite editor

195:40

so as you can see here we have one two

195:42

three four five six seven eight nine ten

195:46

eleven sprites and they are spread over

195:49

800 here below you can see it 858 by 58.

195:54

if we do automatic slicing

195:57

you can see that it does the job pretty

195:59

well but the problem is that when we'll

196:02

be adding other animations to our

196:04

conqueror

196:05

we'll have a slight problem with that

196:08

that's why i'm going to slice it up

196:11

in a manual way

196:13

and it's going to be 58 by 58 we slice

196:17

that up and as you can see it's not very

196:21

accurate

196:22

why is that because we want to have some

196:25

kind of offset

196:27

why we need that offset well because 58

196:29

by 58 just doesn't cut it

196:33

and we are going to pad

196:36

let's do a padding of oh i mean an

196:38

offset of 20 nope i meant padding so

196:42

padding of 20

196:44

and now we can see that they are all in

196:47

the middle the most important thing is

196:49

to have our conqueror inside in the

196:52

middle of the sprite so all of them are

196:55

in the middle and okay great so

196:59

slice that up apply everything

197:02

you can as always i've told you you can

197:04

rename them if you want to go down that

197:06

road so

197:08

we've sliced up our sprites now it's

197:09

time to add our renderer the way we do

197:12

that

197:13

is we'll move this up here and we'll add

197:17

a component and it's going to be a

197:19

sprite renderer and in our sprite

197:22

renderer we have this default sprite

197:24

choose any one you'd like and put it

197:26

inside of it and we have our player

197:30

great

197:32

so now what we need to do is we need to

197:34

add an animator to that player or

197:37

actually an animator component that

197:39

we've talked about so let's do that

197:41

simply type in

197:43

animator

197:45

now we have an animator controller and

197:48

this object can now begin to have

197:50

animations

197:52

back into assets let's create a folder

197:56

we'll call this folder

197:59

animations

198:00

and inside of animations we are going to

198:03

create an animator so animator

198:07

controller and we'll call this the

198:10

player

198:12

now

198:14

let's get back

198:15

what should we do right now okay so next

198:18

step is going to be we're going to open

198:20

up our window for an animation so go

198:23

into animation and click on the

198:26

animator window animations animator

198:30

and we have the animator but we are

198:33

going to dock it in a different way feel

198:35

free to dock it however you want this is

198:38

my personal style so i'll dock the

198:40

project and console next to each other

198:43

and i will dock the animator

198:46

wait of

198:47

what and i'll dock the animator right

198:50

here below oh okay you need to

198:53

do a couple of restructuring right here

198:56

just like that and it's perfect so

199:00

this is our animator right here below

199:03

our scene and we'll add also a window

199:06

for the animations

199:08

so animations and we'll dock it next to

199:11

the animator

199:12

just like that okay great

199:15

next thing we're going to do

199:17

is we're going to create an animation

199:20

and we'll be adding it to our animator

199:24

so as you can see we already have a

199:25

couple of states these are called states

199:28

this is the entry state this is from any

199:31

state and this one right here is an exit

199:34

state

199:35

so let's create an animation the best

199:37

part of our game

199:40

so go back to sprites conqueror and the

199:43

way we create animations is we choose

199:46

all the sprites that we want so as i've

199:48

told you before click on the first one

199:50

go to the last one hold shift click on

199:53

them you've chosen all of them

199:55

right click on it and go to create and

199:59

go down into animation so this will

200:01

create an animation

200:04

and we'll call this idling

200:07

idling

200:09

okay great now we have an animation of

200:12

idling for our player simply drag that

200:15

into animation and inside of animation

200:18

we have to now add this

200:20

idling animation to the animator so we

200:24

do that by simply click on

200:26

click on the id and drag it into the

200:29

animator and now we have an idling

200:33

animation for our player

200:36

one thing we also have to make sure of

200:38

is we click on animation and add a loop

200:41

time because if we don't he'll do this

200:44

animation once and then stop but idling

200:47

is an animation that we want to have

200:50

over and over and over and over so click

200:53

on that

200:54

save all of this

200:56

and don't forget to go to player

200:59

and in the animator controller it will

201:01

ask you for a controller you can either

201:04

drag this

201:05

here or you can click on the little

201:08

circle and add the player animator save

201:11

that

201:12

and now let's click on play and see what

201:15

we've done or if anything works at all

201:19

so

201:20

if we go back to scene we can see that

201:22

our player moves and he

201:24

is idling

201:26

whoop okay great

201:29

very exciting

201:30

it is very exciting but there is a

201:33

problem if we take our player right now

201:36

and drag them into our platform

201:39

we cannot see anything so where is he

201:42

what's the problem the problem is

201:46

well it's actually your problem because

201:50

see what i did there i actually changed

201:52

the

201:53

everything the steps into a

201:56

challenge because maybe you're just

201:58

watching and not doing anything so this

202:00

is your chance to do the challenge so

202:03

your challenge is to do all of the

202:05

things that we've done already you can

202:07

re-watch it maybe you already doing

202:10

everything with me and pausing the video

202:12

but if you're not now is the time

202:14

and your extra challenge is to use the

202:18

sorting layers to make our player

202:20

visible in front of the background so

202:23

we've covered sorting layers before i

202:26

think you have enough skill to do all of

202:29

them and i'll see you in a bit

202:32

welcome back i hope you did your best in

202:36

that challenge i hope you just didn't

202:38

stare at the screen

202:39

so we'll choose player we'll go into

202:42

sprite renderer and we see here that we

202:45

have the sorting layer just as we had

202:47

for the foreground and background

202:50

so if we click on default we don't have

202:52

a player and we can add a sorting layer

202:55

so let's go ahead and do that

202:57

so a new layer will call this the player

203:00

layer

203:01

player layer that's fun to say and we'll

203:04

put it in front of background and behind

203:07

foreground even though he will not be

203:09

going

203:10

over the foreground or behind it but

203:13

we'll render it that way

203:15

save all of that

203:16

back to player and choose the sorting

203:19

layer to be the player so now our player

203:22

our player is on the player layer

203:26

save that 10 times and now

203:28

i actually i think that our player is

203:31

just a little bit small i think we'll

203:34

make him

203:36

bigger so let's go into sprites and the

203:38

way we do that we choose the

203:40

conqueror sprites and we'll make this

203:43

30.

203:44

so if we make this 30 click on apply he

203:47

becomes just a little bit bigger just so

203:49

he can be seen better and if this camera

203:52

logo in here is bothering you it's

203:54

bothering me you can actually click up

203:57

here on the gizmos and you can make all

204:00

the icons smaller you can even make them

204:04

disappear

204:05

okay great so i hope you got on with

204:08

that challenge i hope you are excited as

204:10

i am because our player is actually

204:13

moving and we have

204:15

breathed some life into our game i'll

204:18

see you in the next one

204:20

hey there

204:22

this is michelle from the future sorry

204:24

to interrupt but i want you to do

204:27

something that we haven't been doing so

204:29

far and that is committing our changes

204:33

maybe you've been doing that and i

204:35

congratulate you

204:37

but if you're not this is a great time

204:39

to start doing so as you can see i've

204:41

been doing it each video so slicing up

204:44

sheets creating entire palettes created

204:46

a platform added rules and now we're

204:49

going to add the animation

204:52

so we'll commit that change and

204:54

adding

204:56

animation or adding

204:59

idling

205:01

animations

205:02

so if you haven't been doing the

205:06

repos right here this is a great time to

205:08

start because we are going to be doing a

205:11

lot of things in the upcoming videos

205:14

so i'll see you

205:15

[Music]

205:21

welcome back my fellow game developers

205:24

to a brand new video and this one is

205:28

very exciting because we're going to be

205:30

learning about another other animations

205:33

and even more transitions so as you can

205:35

see here in our animator we've added two

205:38

new states which are climbing and

205:42

running and we've added transitions

205:44

between them we've also added parameters

205:47

that will allow us to make those

205:49

transitions and now if we click on play

205:53

we can actually take our player from the

205:56

idling animation into the running

205:58

animation and we also make a climbing

206:02

animation from what we have so i'm very

206:06

excited for this video i hope so i hope

206:10

you are too so let's get into it

206:14

okay first thing we'll do is we'll go

206:16

and add the sprites for running and the

206:19

climbing

206:21

so for the running we have this run

206:23

sprites and for the climbing i'm going

206:26

to use the fall and the jump because we

206:28

don't have

206:29

the actual climbing animations but i

206:31

wanted to include that in our project so

206:34

go ahead click on all of those

206:37

and drag them into

206:39

our unity so

206:42

we have jump we have the idle the run

206:45

and the fall for now let's just focus on

206:47

the running so as you know this is a

206:51

step that we've done multiple times

206:52

let's go ahead and click on run

206:55

make it multiple make the pixel size 30

206:58

because as you remember we've increased

207:00

the size a bit

207:01

save that and yes i meant to apply

207:05

go back to run and for some reason okay

207:08

so go into sprite

207:10

editor and we have those sprites let's

207:14

go to grid by cell size

207:16

it should be 58 by 58 with a padding of

207:22

20 as i remember yes exactly

207:26

okay so apply that now we have our

207:29

sprites

207:31

let's go ahead and click on all of them

207:33

as we did before check all of them right

207:36

the click

207:37

go to create

207:39

animation and we'll call this

207:41

running so running great

207:44

close that take running into animations

207:47

and later on

207:49

we'll create a folder

207:51

so now let's add the running animation

207:54

state

207:55

to our an anime tour so at running right

208:00

there so now

208:01

this is a bit tricky but let's zoom in

208:05

move that exit

208:06

exit to over here

208:09

and now we have the idling and the

208:12

running next to each other

208:13

so how are we going to tell our animator

208:17

that we want to transition from the

208:18

idling into the running well if you

208:21

right click on idling you can actually

208:23

make a transition so make that

208:25

transition and push the arrow into the

208:28

running

208:29

and if you click on that transition as

208:31

you can see we have lots of options and

208:33

lots of settings also

208:36

so let me tell you just a bit here

208:39

let's talk about transitions we have a

208:41

bit of blending here between the

208:43

animations but we don't want that so as

208:46

you can see we have this blending right

208:48

about here and we can actually

208:51

remove all that blending so it goes

208:54

immediately from idling to running and

208:57

we'll do that because we already have

208:59

very good 2d animations so we can simply

209:02

go into transition

209:04

duration and put it to zero that way

209:06

there will be no lag between animations

209:10

so now we have the idling going to

209:13

running but how is it going to know that

209:15

we actually want to go down that road

209:18

well we do that using the parameters

209:21

here on the left so go from layers into

209:24

parameters and as you can see we have an

209:27

empty list

209:29

so here is where we start adding

209:31

parameters and we can add a couple of

209:34

parameters we can add a float an integer

209:37

a boolean or a trigger for now we'll be

209:40

using a boolean and that boolean will be

209:43

called

209:45

running so if we want to transition into

209:48

running we'll need to use the running

209:51

boolean

209:52

and in order to add it

209:54

under the if we click back on

209:56

transitions we have the conditions right

209:59

here and this condition list is empty so

210:01

we click on plus and it it automatically

210:04

adds the running because we don't have

210:06

anything else to add and now if we click

210:10

on play

210:13

we can see that we are right now in the

210:15

idling and if we click on this boolean

210:18

we go into the running but it does

210:20

it does it only once why is that

210:24

i'll give you a mini challenge right now

210:26

to figure it out

210:29

okay

210:30

enough so let's see running should be in

210:33

a loop

210:34

save that

210:35

back into play and now if we click on

210:38

the boolean he starts running and he

210:40

keeps running

210:42

forever

210:44

why is that we want to make this better

210:47

so we'll add a transition back from

210:49

running to idling and this transition

210:51

will also have

210:54

an a duration of zero

210:57

and its condition right here will be

210:59

running but when it's turned to false

211:02

save that again

211:03

click on play

211:05

and now our player is idling and now

211:08

he's running and now he's not running

211:11

and now he's running

211:13

and now he's not running haha

211:16

okay so this is very cool this is very

211:18

exciting

211:20

and this is a great time for your

211:22

challenge so your challenge is to create

211:25

the climbing animation so import the

211:28

climbing sprites from resources

211:31

slice them up and size them

211:33

appropriately

211:35

create a transition from idling and to

211:38

running and finally create a trigger for

211:42

the transition so pause the video right

211:44

now i given i've given you all the steps

211:47

that you need

211:48

i want you to try your best

211:51

so i'll see you in a bit

211:55

welcome back so how did you get on with

211:57

that

211:58

let's go ahead and do the challenge so

212:01

first thing we'll do is we'll go into

212:03

our conquerors sprite and as i've told

212:06

you we'll be using the fall and the jump

212:09

animation in order to create our

212:11

animation so this will be a bit tricky

212:14

and now we'll go into our file

212:18

so our fall should be

212:20

32 and we'll make it multiple even

212:22

though we don't need to do that but

212:25

because we're going to slice it up

212:28

our way

212:29

so it's 58 by 58

212:32

apply we only have one sprite and in

212:35

here also we have only one sprite

212:38

so apply that don't forget to make it 30

212:41

not 32 so 58 by 58 sliced it up apply

212:46

great so now we are ready to use

212:49

these two so let's click on those right

212:52

click and create

212:55

an animation and we'll call this

212:58

climbing so climbing animation back into

213:02

our animation folder

213:04

and we'll add it into our

213:07

animator will create a transition from

213:10

idling to climbing and a transition from

213:13

climbing to idling will also turn off

213:17

all the transition duration on both of

213:20

them

213:21

and we'll create a new parameter which

213:24

will be a boolean and we'll call this

213:27

climbing

213:29

so climbing

213:30

and now we'll add this condition to

213:33

from idling to climbing the

213:36

climbing should be true and from

213:38

climbing to idling the climbing should

213:42

be

213:43

false

213:44

save that click on play

213:47

did we put it into loop i'm not sure

213:50

let's try it so climbing and it stops

213:53

because we haven't put it into

213:55

looping save that again and now

213:59

if we click on climbing he starts

214:02

climbing but as you can see it's kind of

214:05

super fast so let's go ahead and

214:09

play around with our animation how do we

214:11

do that so

214:13

we have an animation tab right here that

214:15

we haven't used yet so go from animator

214:19

to animation and as you can see here we

214:21

have this climbing if we click on player

214:24

up in the hierarchy we have the idling

214:27

we have the running and we have the

214:30

climbing and if you click on any one of

214:32

those for example idling you can see

214:35

that it tells us which things change

214:38

during the animation for example here

214:41

the thing that is changing is the sprite

214:43

so we can actually take it frame by

214:46

frame or play it right here and we can

214:48

see that our

214:50

player moves with the idling and you can

214:52

see every single frame

214:55

and and you can go forward and backwards

214:58

make it smaller make it bigger

215:00

so we'll use that for the climbing why

215:03

is that because as you saw the climbing

215:05

is extremely fast and we want to slow it

215:08

down just a little bit

215:11

so how are we going to do that

215:13

well it goes from here to here so we'll

215:16

add another one so copy that click on

215:20

ctrl c

215:21

go to the frame with in where you want

215:24

to put this

215:25

sprite and ctrl v

215:28

okay so now we have these two

215:31

well actually let's choose both of these

215:34

and ctrl c

215:36

ctrl v and then again

215:39

so it's three times let's make it one

215:41

second

215:43

okay let's see how that works click on

215:45

play

215:46

it's a bit fast still

215:48

but at least he does it multiple times

215:52

we can actually

215:53

let's take them apart if we choose all

215:56

of these and let's you know what let's

215:58

delete the last two

216:00

and choose all of these and we actually

216:03

can

216:04

spread them out over a second and now if

216:06

we click on play

216:09

it will be just a little bit something

216:11

is wrong right why is that because the

216:14

last frame well actually they're not

216:16

spread out correctly so let's spread

216:18

them out correctly so this is on four

216:22

six

216:23

eight on the one and the last frame

216:26

should be the same as the first frame so

216:30

let's put in

216:32

that one and now if we click on play it

216:35

should be very very smooth

216:38

so

216:39

a final step before we go i want to go

216:42

into

216:44

player i want to go into the animator

216:46

actually and i want to remove the exit

216:49

time as you can see we have something in

216:51

here that's called exit time

216:53

and this is used when you want to

216:56

transition back into the previous

216:58

animation or go into the next animation

217:01

after a certain time and we don't want

217:04

this right now we'll be using it in the

217:06

future so go into every single

217:08

transition

217:10

and remove the exit time

217:14

and we are done so let's save that let's

217:17

click on play and see what we have

217:20

so we have our player idling

217:24

and if we click on running he starts

217:27

running and we unclick on off of running

217:30

he stops and he also climbs

217:33

how cool is that seriously this is the

217:36

coolest part and i hope you enjoyed the

217:38

video i hope you learned a lot and don't

217:43

forget to save in the repo

217:45

and i'll see you in the next video

217:54

[Music]

218:00

welcome back everyone just wanted to

218:02

remind you of the amazing job you've

218:04

been doing so far in this video we'll be

218:07

adding a rigid body and a collider to

218:10

our player we'll also be adding

218:13

collisions to our environment as you can

218:15

see here that will make or enable our

218:18

player to land on the surface of our

218:21

foreground so now if we click on play

218:24

our player actually stands on the

218:27

surface so let's get started

218:31

okay so let's start off by adding a

218:35

rigid body to our player but before we

218:38

do that i think it's a great time for us

218:41

to prefab our player so to do that let's

218:44

go into our assets right click and

218:47

create a folder and we'll name this

218:50

folder

218:51

prefabs

218:52

let's go ahead and prefab our player so

218:57

now we have a player prefab which feels

219:00

good

219:01

so

219:02

back to our player let's go ahead and

219:04

add a rigid body to our player so

219:08

rigidbody

219:09

2d

219:10

and we'll make sure that we have it as

219:12

dynamic save that

219:14

and apply it to our prefab

219:18

the way we do that is we go to overrides

219:21

click on down and there will be an apply

219:23

all okay great before we continue i

219:27

wanted to take a second and talk about

219:29

rigid bodies to the e one more time so

219:33

it's a component added to a game object

219:36

that subjects it to it should not be tp

219:40

it should be two physics engine forces

219:44

and we have

219:45

many body types of rigid body 2d so we

219:48

have dynamic which has finite mass and

219:51

is affected by gravity and other forces

219:54

we have kinematic that isn't affected by

219:57

gravity and other forces and we have

220:00

static which behaves like an immovable

220:03

object

220:04

okay great now

220:06

back into unity and because we have a

220:09

rigid body

220:10

now if we click on play

220:15

our player falls through the ground okay

220:19

not very helpful but it's a step forward

220:22

so now it's time for your challenge it's

220:26

a bit of an early challenge but i think

220:28

you have it covered so we've talked

220:31

about collisions before so now it's time

220:33

to add the appropriate collider to your

220:36

player

220:38

you need to add a collision to the

220:40

environment and you have to make sure

220:43

that your player lands on platform

220:45

without falling through so pause the

220:48

video right now if you feel that you

220:50

have the skills to do that if not

220:53

wait a couple of seconds and i'll be

220:56

right with you

220:57

okay so colliders they are very helpful

221:02

so go into player let's close down this

221:05

rigid body

221:07

and let's go ahead and add a collider so

221:10

i think we'll be adding a box collider

221:13

2d to our player and as you can see

221:16

our play or our box collider is a bit

221:19

too big for our player so we'll go ahead

221:21

and shrink it down

221:23

and you can do this however you want it

221:26

depends on your preference to the game

221:28

how much you want to make the box

221:30

collider big or small but what you need

221:32

to keep in mind is that his feet should

221:35

be touching the bottom of the collider

221:38

so let's make it

221:41

this big

221:42

and this is simply based on your

221:44

preferences i like to keep it just

221:48

smaller than his actual size

221:52

to make the game a little bit fair so if

221:54

you make the box collider bigger

221:57

that will make the game a little bit

221:59

more difficult and if you make it

222:01

smaller it will make it easier for your

222:04

players so

222:05

i think this is good enough so save that

222:09

and as always go to override and apply

222:12

to the prefab so now if we click on play

222:16

our player still falls through why is

222:19

that well because we don't have any

222:22

colliders on our foreground so let's go

222:25

and add some so go into foreground

222:29

and if you got to this point and

222:32

couldn't continue don't worry about it

222:34

because this is something new we'll be

222:36

adding a tile map collider so let's go

222:40

into tile map

222:42

and as you can see all of the foreground

222:45

tiles have been

222:47

have now a collider on them but the

222:50

problem is that if you zoom in you can

222:53

see or you can't but if you zoom a lot

222:57

you can see that there is a tiny tiny

222:59

tiny gap between the colliders and

223:03

believe it or not this will cause

223:05

problem for us later on especially if

223:07

the player is moving or dropping down at

223:10

a very fast

223:12

velocity he can go through these

223:14

colliders so how are we going to fix

223:17

that

223:18

well there is a small solution

223:22

that is called a composite

223:25

collider 2d so let's see what that does

223:28

so composite

223:29

collider 2d when we add that it

223:33

automatically adds a rigid body to our

223:36

foreground

223:37

and what this does it actually

223:40

let's close this and if we click here if

223:43

we look into our tile map collider we

223:45

can see that we have a check box that is

223:46

called

223:47

used by

223:49

composite and what this does if we click

223:52

on it

223:52

you can see that all of the

223:55

colliders are now

223:57

on a single collider but we can't see it

224:00

let's

224:01

make this bigger okay so now you can see

224:04

that we have a single line of collision

224:08

to our foreground so now if we save that

224:11

oh and there is one more problem

224:14

well you should have thought of it maybe

224:16

you didn't that's okay i've missed it a

224:19

lot of times because we have a rigid

224:21

body on our foreground if we keep it on

224:24

dynamic all of the world will be falling

224:28

down so we need to change this from

224:30

dynamic into static that way it stays in

224:34

its place whatever happens so save that

224:38

click on play

224:39

and now our player stands on our

224:43

foreground

224:45

now the game is becoming more and more

224:47

realistic

224:49

so

224:50

this is

224:51

great this is a very big

224:54

leap forward

224:56

but there is one other problem because

224:58

if we click on our player and we set him

225:01

here on the edge

225:03

and click on play

225:05

we can see that he actually

225:08

falls on his head and now the animation

225:10

is placed

225:11

well it is kind of cool you know but we

225:14

don't want that so in order to avoid

225:16

this type of behavior from our player we

225:19

can actually go into our

225:22

not rigid body excuse me we can go into

225:24

i mean into our rigid body and down here

225:27

we can see that we have something called

225:29

constraints

225:30

so this constrains the movement of our

225:33

player on

225:35

certain uh

225:37

rotations for certain rotations so what

225:40

we want is to freeze the rotation on the

225:43

z axis if you look here at the top of

225:45

the transform if we use the z rotation

225:49

our player rotates so this is the one

225:51

that will be freezing

225:53

okay great is it still freezed

225:56

do we need it to override apply all and

226:00

now let's close that

226:02

why is it telling me that i need to

226:04

change my collider okay click on play

226:06

and now our player

226:09

stands using his hammer it's not very

226:12

realistic but

226:15

it's

226:16

a 2d platformer and it's okay we don't

226:19

need it to be very realistic so i hope

226:22

you enjoyed the video i hope you try to

226:25

do the challenge and i'll see you in the

226:28

next one

226:33

hey

226:34

congratulations on making it this far

226:38

you are doing extremely well

226:41

i'm not there sitting with you but i'm

226:43

pretty sure and if you got to this part

226:45

you are doing extremely well

226:48

so i hope you're enjoying keep on going

226:50

we still have a lot to learn so see you

226:53

in just

227:00

[Music]

227:06

welcome back to another video and the

227:09

start of a new chapter in our game

227:11

development journey in this video we are

227:14

going to start moving our player based

227:16

on keyboard

227:18

input will be using the same formula as

227:21

we did for the previous project or for

227:25

the magic game cube but with a different

227:28

twist to it that we'll see in a bit so

227:31

as you can see we press on the right

227:32

arrow he moves right we press on the

227:34

left arrow he moves left and i'll see

227:37

you in a bit

227:40

okay so as the title suggests we want to

227:44

manipulate our game objects behavior

227:48

so what does that need well that needs a

227:51

script and that means coding which is

227:54

very exciting and a bit scary so let's

227:57

go ahead and add a script to our player

228:01

where is our player we already have him

228:04

so let's go to add component and create

228:06

a script that we will call

228:08

simply player down here we have new

228:12

script and we'll create and add a player

228:16

script wait for it to understand what is

228:19

happening

228:20

and okay so

228:23

let's start

228:24

by creating a folder one of my personal

228:28

favorite things to do

228:29

apparently so scripts scripts

228:34

and we'll add the player into our

228:36

scripts great let's double click on that

228:39

that

228:41

and let's wait for visual studio to open

228:45

up and understand everything okay so

228:49

i wanted to initially do

228:52

the initially do the challenge later on

228:54

but

228:55

i think i'll do it just now so if you

228:57

are ready

228:58

you can take the initiative and move

229:01

your player first thing you need to do

229:04

is import a cross plot for platform

229:07

input asset package that i've provided

229:09

you in the resources

229:12

then you create a run method that is

229:14

called from inside of update

229:18

then inside of run use the rigidbody to

229:21

move the player

229:23

and finally add a variable to control

229:26

our speed so it's a bit of a daunting

229:30

task if you think you have enough skills

229:33

to it go ahead and pause the video and

229:35

try it if not and you think it's too big

229:38

of a mountain to climb wait for me i

229:40

will do it in front of you and one more

229:44

thing if at any point you feel that you

229:46

can continue it alone i recommend that

229:49

you pause the video and you do it so

229:52

i'll see you in just a bit

229:55

okay

229:56

welcome back so

229:58

maybe you've tried to

230:01

add the cross platform input from the

230:03

resources i provided you but you can

230:06

also go into unity's asset store and

230:09

search for standard assets which has the

230:13

cross-platform input inside

230:15

what is cross-platform input well it's

230:18

something that we'll be using instead of

230:21

input and it literally does what it says

230:25

what's next what name it is well it's

230:27

cross platform input that means it's

230:31

across multiple platforms so this game

230:34

that we are creating right right now

230:36

could be on a

230:38

computer on a

230:40

pc

230:41

or maybe it can be on a playstation 5

230:44

that's coming out recently

230:46

but of course like this is isn't going

230:49

to be a playstation 5 games but who

230:51

knows maybe you could create a

230:53

playstation 5 from this simple graphics

230:56

anyways let's go ahead and import the

230:59

cross platform package so simply go into

231:02

the resources and drag the cross

231:04

platform package into our assets

231:07

it will ask you

231:09

to do you want to import all of these

231:12

simply click oh what is this okay don't

231:15

worry about that we've already imported

231:17

that and what we do need

231:21

is

231:22

the standard assets so go ahead look for

231:26

cross platform

231:30

on that and now simply click on import

231:33

we only need the cross platform

231:36

assets and if you've downloaded the

231:38

standard assets from

231:40

the internet

231:41

also only choose the cross platform

231:45

there's no

231:46

bad thing to do well if you import

231:48

everything but for now we just need the

231:51

cross platform so

231:52

wait for that to import and now we

231:55

should have a folder that is called

231:57

cross platform

231:59

folder and let's go ahead and add the 2d

232:02

extras which is under the file

232:04

7.15 whatever into our standard asset

232:08

to make everything a bit more

232:11

cohesive as i'd like to say

232:13

save that

232:15

let's go back into visual studio and

232:17

because there is a file modification

232:19

detected it will ask you for a reload

232:22

simply reload

232:25

reload again it shouldn't do it anymore

232:28

everything is fine okay

232:30

so

232:30

first thing we are going to do will be

232:33

adding a

232:35

using

232:36

cross platform

232:38

that means at the top here

232:40

uh i'm not sure i've explained this

232:43

enough

232:44

these are the libraries that we are

232:46

using for example the unity engine

232:49

is

232:50

the library for the start and the update

232:54

and all other

232:55

unity related things

232:57

that we use in our script so now we have

233:01

to import the cross platform library and

233:04

we do that by typing using

233:07

unity

233:08

standard assets dot cross platform

233:12

inputs

233:14

so now we have access to the cross

233:16

platform input

233:18

next thing we're going to do is we're

233:20

going to create a run method this will

233:23

be a private method it will not return

233:26

anything that means it's a void and it

233:29

will be called

233:31

run

233:32

and what should we do inside of run well

233:34

we're going to use the get access method

233:38

and get the horizontal so

233:41

well first thing we're going to do is

233:43

we're going to put it inside of a

233:45

variable so it's going to be a float

233:49

it's going to be

233:51

let's call this

233:53

control

233:54

throw

233:57

and it's going to be you using instead

234:00

of input we'll use cross platform input

234:03

manager it's a big word but it's what we

234:06

use instead of input it's going to use

234:09

dot get

234:10

axes now inside of get axis we'll need

234:13

string name for our inputs and where

234:17

will we get that

234:18

well let's go back into

234:21

unity here and if we go to edit

234:24

and we look for project settings

234:27

we can see that we have our input

234:30

manager that opens up and if you don't

234:32

have it opened up simply click on input

234:34

manager so this is where we have our

234:37

project settings there are a lot of

234:39

things in here we don't need to go over

234:42

all of them

234:43

so for example we have physics 2d which

234:45

we'll be using very soon but for now

234:48

let's focus on input manager we have

234:50

these axes here and if we click on that

234:53

we can see that we have a lot of options

234:56

so and one of them is the horizontal so

235:00

horizontal is when we click on the a or

235:03

d and this is exactly what we need so

235:07

because

235:08

in here the get axis needs a string

235:11

reference

235:12

we'll go back into the input manager and

235:15

every time we have a string reference we

235:18

always go and copy it we never assume

235:22

that we've written it correctly

235:24

because we never do and we cannot find

235:26

the error so

235:28

we have a control throw and why did we

235:31

use a float variable to catch this input

235:34

because i will demonstrate it so if we

235:37

click here print

235:39

and we'll

235:41

let's go where is it control throw let's

235:44

print that out and see what happens and

235:46

let's not forget to call it in the

235:49

update method so save that

235:51

back into unity

235:53

let's dock this here next to

235:56

our tile palette

235:59

that's i think is a good place

236:01

and now if we click on the play

236:05

and we click on the left ma on the left

236:08

arrow you can see that it slowly goes

236:10

from zero

236:12

to minus one and then back to almost

236:15

zero and if we click on the right arrow

236:17

it goes from zero slowly to one and

236:21

that's why we need to save it inside of

236:23

a variable to always have control over

236:26

it so now that we have it let's delete

236:28

this print right here

236:31

it was only to demonstrate how this

236:33

works

236:34

next thing we're going to do is we're

236:35

going to create a player velocity of

236:38

vector type 2.

236:40

so

236:41

we'll do that by first getting the rigid

236:45

body

236:46

so let's create a variable right here

236:48

that is the rigid body so

236:51

it's a rigid body 2d i will call it my

236:55

rigid

236:57

body

236:59

2d

237:00

and previously we've used we called this

237:04

a public variable and we've added it

237:06

from the inspector but now i'm going to

237:09

teach you a much better and

237:12

maybe more efficient way to do that in

237:15

code so the way we're going to do that

237:17

is and start we're going to call our

237:21

variable

237:23

and we're going to assign to it

237:25

the rigid body that is currently

237:28

sitting on our player game object so

237:32

we'll use get component

237:34

which gets a certain component and what

237:37

that component is

237:39

well it's a rigid body 2d

237:42

and that is how it's written now we have

237:45

a reference to our rigid body to

237:48

d

237:49

and let's go ahead and change it and

237:52

run so

237:53

we'll click on here it's my rigid body

237:56

2d now before that let's create a

237:59

variable for our place velocity

238:02

and that variable is going to be a

238:04

vector 2

238:05

we'll call this player velocity

238:10

velocity

238:12

and this player velocity will be equal

238:14

to a new vector 2

238:17

and we'll move we are moving this in the

238:20

horizontal axis

238:22

so

238:23

we will only be changing the velocity in

238:25

the x or horizontal direction so this

238:29

will add the controls row to the x

238:33

axis and to for the y we'll simply keep

238:36

it as my rigidbody

238:38

dot

238:40

velocity

238:42

dot y so in the y direction the velocity

238:45

will not change and finally we'll assign

238:48

the my rigid body to the dot velocity

238:52

will be equal to the player velocity

238:55

that we've currently created so save

238:57

that

238:58

let's go back into unity and see if we

239:01

did anything correctly so

239:03

click on here our player falls if we

239:06

move left

239:07

he slowly moves to the left and if we

239:09

move right he also slowly very slowly

239:13

moves to the

239:14

right okay

239:16

excellent

239:18

as you've seen he moves very slowly and

239:20

we'll need to fix that in order to do

239:23

that we are going to create here a

239:27

variable for the run speed so

239:30

let's go ahead and create something we

239:33

call a serialized field oh very

239:37

scary

239:38

some fancy words you using michelle

239:42

don't worry i will explain what that is

239:44

and serialized field is just like public

239:48

where we can change the variable from

239:50

our inspector but the only difference is

239:53

that we can actually manipulate that

239:56

variable from a different script

239:59

okay so like we use public functions to

240:02

change

240:03

well to use functions from different

240:05

scripts we can actually use serialized

240:07

field to change variables and i don't

240:11

think we'll be using it too much but

240:13

let's say for example you want to change

240:16

your player speed for example depending

240:18

on the platform you're standing on you

240:21

can go ahead and do that using the

240:24

serialized field

240:25

okay small explanation let's continue

240:28

we're going to make this run speed a

240:30

float and we'll call this simply run

240:34

speed

240:35

and what should this run speed be

240:37

we can actually do

240:39

something let's try 10 f

240:42

and we are going to multiply it with the

240:45

controls row right here so run speed not

240:49

run

240:50

actually let's run speed

240:53

and now

240:55

if we go back into

240:57

unity

240:58

and click on inspector

241:01

then click on player now we can see that

241:03

we have a rans run speed of 10

241:06

so we go into play mode

241:08

we can move now with a speed of 10 and

241:10

we can actually increase this to 100 see

241:14

what happens and our player what did you

241:16

see did you see what just happened you

241:18

see how our player disappeared or

241:20

actually you can still see him right

241:22

here in the bottom left corner don't

241:25

worry about that we'll see a couple of

241:27

more instances of this but we'll be

241:29

fixing it later on in the other videos

241:33

so

241:34

i hope you enjoyed uh

241:36

this is the part where our player comes

241:38

to life and we start manipulating him

241:42

using code and everything is fun

241:44

everything is very cool i hope you

241:46

enjoyed and i'll see you in the next

241:50

video

241:51

[Music]

241:56

welcome back everyone our player now

241:59

moves in the game but the problem is

242:02

that he does a moonwalk so whenever

242:05

we're moving backwards he does not flip

242:08

he simply does a moonwalk and we don't

242:11

want that in this video we are going to

242:13

be flipping our player so if we click on

242:16

play

242:17

we can see that whenever we move to the

242:19

right we move right but

242:21

when we start moving to the left we

242:23

actually flip our player and now he

242:26

moves in the direction and actually

242:28

looks in the direction he's moving the

242:30

correct one so

242:32

very exciting let's not waste any time

242:35

and let's jump in and get started

242:38

okay so

242:39

how are we going to flip our player in

242:43

the direction that he is moving

242:46

first thing we're going to do is we're

242:48

going to apply all of our changes to the

242:51

prefab so if we look closely at our

242:54

player we can see that he moves left and

242:56

right but he does not flip

242:58

how are we going to go about this

243:00

if you go up into our transform you can

243:03

see that we have position rotation and

243:06

scale

243:07

so scale if we increase the scale of our

243:10

player in the x direction you can see

243:12

that he gets bigger and bigger and

243:14

flatter and flatter but if we reduce it

243:19

to

243:20

0.3 he gets smaller but what happens if

243:24

we go beyond the zero if we go to minus

243:27

territory we can see that our player

243:30

flips

243:31

so at minus one our player is facing the

243:34

other direction and this is what we are

243:37

going

243:37

to be doing but in our code depending on

243:42

the direction our player is heading in

243:45

and we'll do that using math but not

243:49

very hard math if you don't like math it

243:51

will be simple

243:53

math

243:54

okay so

243:56

now let's go into our visual studio and

243:59

let's go ahead and create a function

244:02

that will call

244:03

private

244:04

void

244:06

flip

244:08

sprite script

244:10

sprite so we have flip sprite

244:14

and we are ready to go so flip sprite

244:18

before we start i need to explain two

244:20

concepts first of all math.apps

244:23

so i hope you remember from school what

244:26

absolute value means

244:28

it means it returns the absolute value

244:31

of something so for example if we have

244:34

math dot abs minus 4 it returns 4

244:38

and math dot sign so what is math.sine

244:41

it returns the sign of a certain number

244:45

that means if we have math sine minus 4

244:48

we have minus 1 as a result and if we

244:51

have math sign 4 we have plus 1 as a

244:55

result so this is a quick overview of

244:58

overview of first grade math or

245:02

something like that

245:03

let's go back

245:04

and let's go ahead and create a boolean

245:07

so

245:08

so i went into visual studio so in this

245:12

we are going to create a boolean which

245:15

will tell us

245:16

if our player is actually moving

245:20

so

245:21

let's go ahead and create a bull

245:23

which will be

245:25

running

245:26

hori

245:31

running horizontally

245:33

not sure if horizontally takes two s or

245:35

just one

245:36

or actually horizontal the a is not in

245:39

the right place okay so horizontally

245:42

equals

245:44

math

245:45

dot

245:46

absolute value

245:48

my rigid body

245:51

to the dot velocity

245:54

dot x now you might be wondering why are

245:57

we even using the absolute value of our

246:00

rigid body's velocity well because when

246:03

we are moving in the

246:05

left direction our velocity is negative

246:08

and we are when we are moving in the

246:10

right direction our velocity is positive

246:13

so we need to take the absolute value to

246:15

make sure that we always know when our

246:18

player is moving

246:19

and to make this boolean because right

246:22

now it's not boolean we're going to

246:25

check if it's bigger than

246:27

wait for it math

246:29

f dot

246:31

epsilon okay now

246:33

again michelle you're using very scary

246:37

words what is math dot epsilon so first

246:40

of all when we type math.f that means we

246:43

are accessing the library of math where

246:46

we have a lot of functions and a lot of

246:50

methods to use and epsilon is not a

246:53

method nor is it a

246:55

function it's a

246:58

a small number a very very very small

247:02

number like say for zero and

247:05

four or five zeros after it and one so

247:08

why are we using math dot epsilon why

247:11

not simply compare it with velocity

247:13

equal zero if you remember in the

247:15

previous video when we tried to print

247:18

the control throw you can if you

247:20

remember whenever we went to the left it

247:23

slowly moved from 0 to

247:25

-1

247:26

and then it went back to minus 0.009

247:33

it never went back to absolute zero

247:36

that's why we are using math f dot

247:39

epsilon instead of

247:41

simply using zero

247:43

next thing we're going to do is we're

247:45

going to use an if condition so

247:48

if

247:50

running

247:51

horizontally

247:53

and inside this if condition

247:56

i'm going to issue you a challenge and

247:59

your challenge is to complete the if

248:02

statement so we are going to flip our

248:06

players sprite based on the direction

248:08

they are moving

248:10

and let's i'll give you a couple of

248:12

hints one will use

248:14

transform.localscale and that's how you

248:16

access the scale of a game object

248:20

and you will be using use math f dot

248:23

sign to determine the direction

248:26

in which our player is

248:29

moving so

248:30

pause the video right now give it your

248:33

full concentration your full thinking

248:36

ability and do the challenge i'll see

248:39

you in a bit

248:41

okay welcome back so what should we

248:44

write inside of our if condition so

248:47

it's

248:48

transform

248:50

because we need access to our transforms

248:53

local scale

248:55

and this local scale in fact is a vector

248:59

2

249:00

because it's 2d so we'll be

249:03

using the scale on the x and y so it's a

249:06

new

249:07

vector 2

249:10

and what should be right for the x and

249:14

the y scale should stay the same that

249:16

means it's going to be

249:18

one f

249:19

okay

249:20

but what should the x be

249:22

well the x will be depending dependent

249:26

on the direction so we're going to write

249:29

math f

249:30

dot

249:31

sign because it depends on the sign of

249:35

the direction

249:36

and what direction is that it's the my

249:40

right body dot velocity

249:43

dot x

249:44

so now

249:46

save that so now

249:48

if our player is moving to the right the

249:51

velocity will be positive and the sign

249:54

will be positive our scale will stay one

249:59

but

249:59

if the player's velocity is to the left

250:03

that means the velocity is negative that

250:06

means the sign is minus one and that

250:09

means that our local scale

250:12

x will be -1 so let's see if that works

250:17

save that and a small mini challenge i'm

250:20

going to give you right now

250:23

where do we actually use this flip

250:25

sprite

250:27

where should we put it inside of our

250:29

code to flip our player

250:32

i'll give you a second to think about it

250:36

one mississippi

250:38

two mississippi

250:40

three mississippi okay time's up it's

250:43

inside of run because we're only be

250:45

using the flip sprite whenever we are

250:48

running save that go back into unity

250:52

let's move out of

250:53

the camera click on play and now if we

250:56

move right we move

250:59

right if we click on the left arrow we

251:01

actually flip and how cool is that

251:05

okay great so i hope you enjoyed the

251:08

video i hope you did the challenge and

251:11

i'll see you in the next one

251:18

[Music]

251:23

welcome back everyone to a brand new

251:26

video and this video we are going to be

251:29

changing our players state from our code

251:32

so as you can see right now we have our

251:34

player in the idling idling state as

251:37

soon as we start the game and if we move

251:40

him left or right you can see that his

251:43

state changes into running and if we

251:46

stop he changes back into the idling

251:48

state so let's not waste any more time

251:51

and let's get started

251:54

okay so let's start off first of all by

251:57

re-explaining what is happening in our

251:59

animator first off we'll make it a bit

252:02

bigger and zoom in

252:04

so first thing we'll need to take notice

252:06

of is here in entry

252:09

from entry we have a transition directly

252:12

into idling and what this means is that

252:15

as soon as our game starts we go

252:18

directly into the idling animation

252:21

and from there we have two options or

252:24

two states to go to we have the running

252:27

state and we have the climbing state and

252:30

both have transitioned to and from so

252:34

for example to go from idling into

252:37

climbing we can see that we have this

252:39

white arrow line

252:42

that has a condition on it and that

252:44

condition is for a boolean to be

252:48

a boolean called the climbing to be true

252:51

and in order to go back from the comedy

252:53

climbing state or animation this

252:56

climbing condition needs to be false and

253:00

the same holds true for running so the

253:02

transition from idling into running

253:05

needs for a certain

253:07

boolean to be true and to go back from

253:10

the running state we need a certain

253:13

variable or a parameter which is running

253:16

to be false

253:17

so how are we going to do that using our

253:21

code well first of all because the

253:23

parameters are present on our animator

253:26

what we need to do is get a reference to

253:29

our animator so let's go into visual

253:32

studio and try to do

253:34

just that so

253:36

here we are in our visual studio first

253:40

thing we'll need is a reference to our

253:42

animator and we'll do that the same way

253:44

we've done to get a reference to our

253:47

rigid body so let's go ahead and create

253:50

a variable

253:52

for our animate so we'll create an any

253:56

meteor animator please so an animator

253:59

will call this my

254:02

animator

254:04

and we'll use the get component to get a

254:08

reference to our animator so get

254:10

component

254:13

animator

254:14

and close that up save that great so now

254:18

we have a reference to our animator next

254:22

thing we'll need to do first we'll be

254:24

focusing on the running so how will we

254:27

change

254:28

from a

254:30

idling where is that so from idling into

254:34

running how are we going to change that

254:37

well we'll have to set the boolean

254:39

because we know that it is a boolean

254:42

let's go back

254:44

and in running when we start to run

254:47

let's go ahead and

254:49

go into the running state

254:52

so we'll do that by using my animator

254:55

which is our reference dot

254:58

and it has multiple

255:00

methods attached to it and one of them

255:03

is the set

255:05

bool and this allows us to send it a

255:08

reference actually it has two

255:11

ways of giving it parameters the second

255:13

way is our way which gives it a string

255:16

and the boolean value that we wanted to

255:19

have so the string reference name and

255:22

the bool value which can be is either

255:25

true or false so let's do that first

255:29

thing we'll need the string name

255:31

and because it's a string reference

255:33

we'll simply go back into unity double

255:36

click and copy that

255:38

reference

255:40

because as we know whenever we have a

255:41

string reference we always always go and

255:44

copy it and now we need to set the value

255:47

for it and of course it's going to be

255:50

true now this is not the final solution

255:53

by any means but this will demonstrate

255:55

how the set pool in my animator works

255:59

so let's go back into unity and see if

256:01

that worked if we click on play right

256:04

here

256:05

our player goes into the running

256:07

animation

256:09

it's good it's not bad

256:11

at least we know it's working but this

256:13

is not how we want it we want it to go

256:15

back to idling whenever we stop the

256:18

running state

256:20

so

256:21

that is going to be your challenge and

256:23

your challenge is to stop the running

256:26

animation

256:27

so you need to add to our run method

256:30

a way to stop the running animation and

256:34

that means going back to the idling

256:38

so it should stay true while the player

256:41

is running and falls when the player

256:43

stops

256:45

use the code we've created when flipping

256:48

the sprite so

256:50

pause the video right now and go ahead

256:52

and do the

256:54

challenge okay welcome back so how did

256:57

you get on with that i hope it wasn't

257:00

very hard

257:02

or i hope it was at least a bit

257:04

challenging so

257:06

let's see what we need to do well

257:08

because i've told you we'll need to use

257:10

something from the flip sprite method we

257:12

are going to check if our player is

257:15

actually running and we'll do that by

257:17

simply copying the following line which

257:21

checks if our player has a velocity

257:24

on the horizontal plane

257:26

so now we have a boolean for

257:29

running horizontally

257:31

and what we can do because this is

257:34

actually a boolean and it's true

257:36

whenever the player is running and false

257:38

if the player is not running we can

257:41

directly set it right here in our

257:44

animator so we'll replace that with no

257:47

sorry i mean running

257:50

running horizontally

257:52

and let's do one more step and that is

257:55

extracting this method method

257:58

into an outside one because it's just a

258:01

bit different we'll call this

258:04

changing

258:06

to

258:08

running state

258:10

and now we save all of that we have a

258:13

our changing to running state which

258:16

checks if our player is

258:18

moving in the horizontal plane and if he

258:21

is that means our running horizontally

258:23

is true that means our animator sets the

258:26

running to

258:28

true and if he's not

258:30

running this running horizontally will

258:32

be false and hence

258:34

our animator will suddenly running

258:37

to false so let's go ahead and see if

258:40

that worked click on play

258:43

our player is initially in the idling

258:45

animation or state and now if we move to

258:48

the left he starts his running if we

258:51

stop

258:52

he stops and goes back into idling

258:55

great so

258:58

this is the foundation of controlling

259:00

our animations from our code we set up

259:03

our state machine

259:04

we have parameters which we can access

259:07

in our code when a particular thing

259:11

happens we can manipulate those

259:12

parameters using our

259:15

code and changing the player state i

259:18

hope you enjoyed the video and i'll see

259:20

you in the next one

259:22

[Music]

259:27

welcome back my favorite game developers

259:30

in this video we are going to add the

259:33

ability to our player to jump so as you

259:36

can see he can now reach platforms that

259:39

were

259:40

unattainable before and he can jump from

259:43

one platform to the other and as you can

259:45

see it's very snappy it's very exciting

259:48

and it's going to be very very fun so

259:53

let's not waste any more time and let's

259:55

jump in and get started

259:59

okay so

260:01

first i want to talk about the jumping

260:03

mechanics and how they are

260:06

so

260:07

the jumping mechanics will be a bit

260:09

different than the running mechanics why

260:12

is that well because running is

260:15

different than jumping

260:17

while because when we run we actually

260:20

pick up speed slowly but when we jump we

260:23

technically

260:25

immediately have a velocity upwards so i

260:28

just want to show you

260:30

how our

260:32

velocity actually increments so if we

260:35

bring the

260:36

player velocity to our console right now

260:40

let's go ahead and try that

260:44

as we start to run with our player you

260:46

can see that it's zero zero when we

260:48

start running to the right it increments

260:51

slowly from zero to nine point seven

260:53

nine 9.8 and eventually to 10

260:56

then goes back to 0 and and the same

260:59

goes when we click on the left arrow but

261:02

we don't want that in our game we

261:05

actually want our player to immediately

261:08

jump as soon as we press the space bar

261:10

or whatever button we would like it to

261:13

be pressed

261:14

and we'll do that using a different kind

261:17

of function than the get access we'll be

261:19

using the input dot get button so if you

261:22

read the description right here you can

261:24

see that it returns true so it's a

261:27

boolean it returns a true during the

261:30

frame the user pressed down the virtual

261:33

button identified as button name anyways

261:36

what you need to take out of this is

261:38

that it immediately

261:40

turns something into true and then back

261:43

to false if we pressed a button and

261:46

that's what we're going to use and of

261:48

course instead of input we'll be using

261:50

cross platform input manager

261:54

because as we as we've said before we

261:56

want this to be a multi-platform game

262:00

and let's jump in and get started with

262:02

it so first thing we'll do is we'll

262:05

remove this print because it's done its

262:07

job it's finished its service

262:10

and we're going to create a function or

262:13

a method right here which we'll call

262:16

simply jump and now if we save that we

262:20

have the option to extract we have this

262:22

little light bulb light bulb on the left

262:25

click on it and click on generate method

262:28

don't worry about whatever is written

262:30

already inside of it it's a private void

262:33

method just as we want so

262:36

what are we going to do

262:38

well first thing we're going to do is

262:40

we're going to

262:42

use a well create a boolean and that

262:44

boolean is going to be called is

262:48

jumping and that is jumping is going to

262:51

get an input from the cross platform

262:53

input manager

262:55

and we'll use the function that we just

262:57

described the get button down so let's

263:00

open that up open it up and we can see

263:02

that it takes a string

263:05

reference as an input

263:07

so let's go ahead and find the string

263:09

reference of the jumping input

263:12

we go into project settings that that is

263:15

docked here on the right so click on

263:18

that

263:19

make this a bit bigger

263:21

and let's scroll down and see where we

263:23

have the jump there it is so it's jump

263:26

and it's positive button is space

263:29

so let's copy this because it's a string

263:31

reference and as we've said before

263:34

whenever we have a string reference we

263:36

always always always go and copy it so

263:40

now we have the is jumping boolean set

263:43

and ready next thing we need to do is

263:46

we'll need to add velocity to our player

263:49

in the y direction

263:51

so let's go ahead and do that so

263:54

we'll create an if condition

263:57

and if

263:58

is jumping

264:00

that means if our player has pressed the

264:03

jumping button we'll create a vector2

264:07

we'll name this jump

264:11

velocity

264:13

and this jump velocity will be equal to

264:15

a new

264:16

vector 2

264:18

and in the x direction we'll only have

264:22

my

264:23

i mean my rigid body so my rigid body 2d

264:27

dot velocity

264:30

dot x

264:31

and in the y direction we will want to

264:35

add

264:36

a velocity speed for jumping and this

264:40

will be dependent on your preference it

264:42

could be 5 it could be 10 it could be 20

264:46

and whenever we have such a

264:49

variable well when we have something

264:52

that is variable it's much better to

264:54

create a variable for it just as we did

264:57

here below for the run speed so let's go

265:00

to the top and create a serialized

265:03

field and serialized field is something

265:06

that we can adjust from different

265:08

scripts maybe we won't need it right now

265:10

but let's just go ahead and make it a

265:12

serialized field

265:14

so it's a float

265:17

what float and it's go we're going to

265:20

call it

265:21

jump

265:22

speed and initially let's go ahead and

265:25

make it 15

265:27

15

265:28

f

265:29

because it's a float so 15 f

265:32

and let's add it to our jump velocity

265:36

okay great and as a final step we need

265:39

to

265:40

add this velocity

265:42

jump my rigid body dot velocity

265:46

velocity is equal to our jump um

265:50

jump

265:52

velocity okay great so save that let's

265:56

go back into unity and see if that

265:59

worked make this a bit smaller click on

266:02

play

266:03

and now we move left and right and if we

266:05

press the space button we can see that

266:08

we jump but that jump is a bit

266:11

floaty as you can see but at least it's

266:13

a start it's a huge leap forward in our

266:17

game development journey get it leap

266:19

forward

266:21

okay i will not make the joke again so

266:24

let's see what we can do in order to

266:26

make this game a bit more snappy

266:29

so

266:30

we can see here that we have a physics

266:33

2d option in our project settings and

266:35

what this allows us to do

266:37

is that allows us to adjust the physics

266:40

to the of our unity engine and we have

266:43

many many options to adjust we have

266:46

maximum rotation speed we have

266:48

translation speed we have angular

266:50

correction we have a lot of stuff in

266:53

here i will leave a link in the

266:55

resources to go check out the physics 2d

266:58

in the unity documentation you can go

267:00

into every single detail that you want

267:03

but for now we're only interested in the

267:05

gravity right here and as you can see

267:08

our gravity currently in the x direction

267:10

is 0 and in the y direction it's minus

267:13

9.81

267:15

which is exactly the same gravity that

267:17

we have here on our planet so if we

267:20

click on play

267:23

and we jump we can actually adjust this

267:27

right here so if we make it for example

267:29

-27

267:30

now if we jump

267:32

we don't jump as high as we did before

267:35

so this is where we begin to tune our

267:38

jump depending on how high and how

267:41

snappy we want our game to be

267:44

and a small reminder whenever we finish

267:47

adjusting something in our play mode if

267:49

we unclick from play you can see that it

267:52

goes back to its original value so keep

267:55

that in mind

267:56

because you need to remember the value

267:58

that you chose when you were in play

268:02

mode and that takes us right into our

268:05

challenge and our challenge or your

268:08

challenge is to adjust your jumping so

268:11

tune the gravity and jump speed to make

268:14

the jumping mechanic to your taste

268:17

and base your tuning on how many tiles

268:20

you want your player to be able to jump

268:22

so you can either make it two tiles

268:25

three tiles you can make him the best

268:28

and highest jumper in the entire world

268:31

it solely depends on your preference and

268:34

how you want to make your game feel so

268:37

pause the video right now and go ahead

268:40

and do the challenge

268:42

okay welcome back i hope that wasn't too

268:46

hard i hope you enjoyed that type of

268:48

challenge

268:49

so let's click on play and see what our

268:51

player does so

268:53

we move left and right and we jump and

268:56

that jump is a bit

268:58

too

268:59

nausea i think so let's make this

269:02

gravity 100 and now it's a bit more

269:04

snappy

269:05

and in order to help our player jump

269:08

higher let's click on player go to its

269:10

inspector and let's make the jump speed

269:13

i think 50. so let's see 15. now our

269:16

player jumps and you can see that he

269:18

actually disappears below the platform

269:21

which is not good and we faced this

269:24

problem before as you can remember from

269:27

i think it was when we added the run

269:29

speed to him

269:30

so we need to fix that before we

269:32

continue

269:34

i don't know if you face this kind of

269:36

problem while doing the challenge i hope

269:38

you didn't and it's not very hard

269:40

actually if we go into our players rigid

269:43

body you can see right here that we have

269:46

something called collision detection and

269:49

it's currently on discrete and if we

269:51

click on the list we can see that we

269:53

have another option which is continuous

269:56

and this is what we're going to choose

269:58

for our player now what what does that

270:01

mean well discrete is it checks for

270:04

collisions every

270:06

certain amount of time while continuous

270:09

is as it says it's continuously checking

270:12

for collision every

270:14

i think micro second or

270:17

millisecond i'm not sure but discrete is

270:21

for example every one or two seconds it

270:23

checks for a collision

270:25

and the continuous checks constantly

270:28

constantly for collisions now why do we

270:30

have the discrete option because we

270:33

might not have a body that it's very

270:36

fast or for example a slow moving

270:39

bird or something that will not need a

270:42

continuous collision with things around

270:44

it but if we have something like our

270:46

player for example right here that has a

270:49

gravity that is 100

270:51

he falls right through our

270:54

world so we'll make it continuous

270:56

continuous is a bit more uh

270:59

heavy on the processor of unity but it's

271:02

okay we can handle that i'm sure so

271:04

click on apply

271:06

go back into projects let's make this

271:09

let's make this gravity 200 because

271:12

i think we'll need it to be 200 let's

271:15

make the jump speed 50.

271:17

save that go back into play mode and see

271:20

if

271:21

that feels nice

271:23

it does feel nice so

271:25

let's see

271:26

i think it might need

271:28

the snappiness to the ground i think the

271:30

gravity is perfect

271:32

let's see if we want to make i think

271:35

that's enough i think 50 for a jump

271:37

speed is perfect so

271:39

i hope you tuned it to your preference

271:42

you don't have to make it just like me

271:44

you can have it whatever you want it's

271:46

your game it's your preferences and i'll

271:49

see you in the next video

271:52

tony robbins once said if you want to be

271:55

successful find someone who has achieved

271:58

the results you want copy what they do

272:01

and you will achieve the same results i

272:03

would love to teach you all about game

272:06

development and the best way to learn

272:08

anything is by doing it in a fun way

272:10

using unity's engine 2d we are going to

272:13

build our 2d platformer my name is

272:16

michael moore founder of double m game

272:18

dev and my goal is to make you the best

272:21

game developer in the most fun way

272:23

possible i've developed a strategy that

272:26

has helped thousands of aspiring game

272:28

developers achieve their goals of

272:30

creating real world games and i want to

272:32

do the same for you what i've learned is

272:35

that it can be very difficult to know

272:37

where to start and what steps to take to

272:40

go from beginner to intermediate to

272:42

professional not only in game

272:44

development but in programming and

272:46

learning how to code and i can say with

272:48

absolute confidence this course makes it

272:51

easy for any beginner with zero coding

272:54

experience to jump in and start learning

272:56

how to create incredible games and the

272:59

most amazing part is is that we're doing

273:02

all of this with the latest version of

273:04

unity with the newest techniques and

273:07

content in modern game development i've

273:10

helped thousands of people create real

273:12

world games and i want you to be one of

273:15

those people so how are we going to do

273:18

this first we are going to build the

273:20

foundation by learning the fundamental

273:23

aspects of c sharp programming we'll

273:25

understand what variables are how to do

273:28

if statements and create our own methods

273:31

and functions enabling us to make

273:34

incredible gains and while you're

273:36

building confidence in those areas we

273:38

are going to be playing in unity's

273:40

engine you'll understand how the

273:42

interface works how you can easily add

273:44

game objects and get comfortable with

273:47

everything available to you in unity and

273:50

the third component and most important

273:52

one is the game design side of things

273:54

where we'll talk about player experience

273:57

and create something enjoyable for

274:00

anyone looking to play your game we'll

274:02

then move on to more advanced sharp that

274:05

will enable us to control our game and

274:08

everything in it in a much better way

274:11

while still keeping our code readable

274:14

and very easy to understand we'll then

274:16

delve deeper into unity's tools that

274:19

will allow you to enhance your players

274:21

experience enhance your learning and

274:24

expand the horizon of the games that you

274:27

can make

274:28

and will create a synergy between

274:30

c-sharp programming unity's engine and

274:33

game design and from it build an

274:36

incredible and fun game so what should

274:39

you expect by the end of this course

274:41

you'll become a master problem solver

274:44

you'll understand the fundamentals of

274:46

coding and learn how to program games

274:48

just like the ones you're seeing on the

274:50

screen right now

274:51

you'll also have the chance to flex your

274:53

game developer muscles because with

274:55

every video there is a mini challenge

274:58

for you to complete and even if you

275:00

can't figure out how to do the challenge

275:02

don't worry i will be there to help you

275:04

after you tried and complete the

275:06

challenge with you everything in our

275:08

game will be configurable so you can

275:10

tweak play around and give the game an

275:13

individual and special feel about it so

275:15

you will be putting your own creativity

275:17

into it and really making it your own

275:19

i'm so excited to get started and hope

275:22

you are too this is the perfect time to

275:25

start learning how to code so dive in

275:27

with me and i will help you along every

275:29

single step of your game development

275:32

journey

275:42

you

UNLOCK MORE

Sign up free to access premium features

INTERACTIVE VIEWER

Watch the video with synced subtitles, adjustable overlay, and full playback control.

SIGN UP FREE TO UNLOCK

AI SUMMARY

Get an instant AI-generated summary of the video content, key points, and takeaways.

SIGN UP FREE TO UNLOCK

TRANSLATE

Translate the transcript to 100+ languages with one click. Download in any format.

SIGN UP FREE TO UNLOCK

MIND MAP

Visualize the transcript as an interactive mind map. Understand structure at a glance.

SIGN UP FREE TO UNLOCK

CHAT WITH TRANSCRIPT

Ask questions about the video content. Get answers powered by AI directly from the transcript.

SIGN UP FREE TO UNLOCK

GET MORE FROM YOUR TRANSCRIPTS

Sign up for free and unlock interactive viewer, AI summaries, translations, mind maps, and more. No credit card required.