Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Ok so what's going make level 2
I just press ctrl d
With this level one selected here
And I was just little 2 on it open today
So just for the purposes of this tutorial that shift the player over to a start location of maybe here
Let's maybe change all of these graphics back here
Maybe not be purple but let's do full-time Game Dev till
I like that brand colours so we do that
Let's do a teal colour
Something like that would be good
I'm saying for this year
Teal colour
Increase the saturation
Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1
And it'll be a little bit messy right here bye
Overground here maybe your platforms as well
Select all of those is kind of
Artistic
You give me patient right
And I maybe you can get this game done alright so let's go to blue here
A girl
Awesome
It's pretty good
And
We don't really need to change the
Black foreground here looks fine looks like we missed one here it's ok
Use the eyedropper tool
Tuesday dark blue
In the final thing we want to do is just go to a camera this year
Thermal camera how much like this boy here and maybe go a little prayer in a little bit later
Alright so now
Level two
Rico
Maybe ship some things around so maybe move that are here and I know this is just for the purpose
This tutorial
If you delete
Dilip dad dad The Spinney here and
Razor this
Building here I don't know you guys get the portrait
What is changing this level for this tutorial
So we got bullied in the background
We're clearly another to write colour just changed
Awesome
Play make sure everything works
So now let's Create
Trigger double load this level for us
After we beat level 1
Another one here
What we're going to do is going to create a new empty gameobject
I'm going to add a box Collider 2D to it
It's going to be a Trigger
What's use the scale tool in just sort of scale is up pretty back here something like this
Just started to play a king
Absolutely 100-percent can't avoid
This little triggers on here
This object seem load Trigger
Shall we put that in to layer one here
Where the player can walk
There's no parallaxing are coming so they can we miss it
Ok so you see shark script
I'm really cold this scene load Trigger
James Cranswick shares par for the course of the unity that's ok
Lower trigger here
Game object we can actually just drag this year
And now we have the Script attached to a scene on trigger
Let's just be sure to make cmode trigger a prefab cos they were going to be using this all right every levels
Another level in we're going to have
Linear game where we can go from one level to the next from left to right
Ok let's go ahead in open up and see no Trigger
And you probably guessed it were going to use on trigger enter
Because I'm an idiot remember how the right ontriggerenter2d
Copy it from the attack box here or we can do it from the enemy or anything like that just copying
Delete the
Inside of this function here
Pseudocode anymore do it guys we just write this
The collider2d which is col col
Object equals
New player
Instant start game object
Then later seen that again that was seen
Manager
Start
Load scene ok
And then we're going to load the next scene which is Level 2
Perfect
Looks like automatically it added a scene management namespace here that's pretty cool I didn't know it did that
Assassin
So if you don't see that
Can you see a zigzag here
I got to do is show potential fixes
Enniskillen put that namespace in there which allows us actually love scenes
Now summer thinking the timer sometimes with no one allowed a different seen maybe level 3 A level four
Maybe another one or a main menu
Thinking that's awesome it's crazy variable appear serializefield
Give me a private string and loadscene string
And we just remove everything here
And then jump back in the Unity
Now we can specify which
Seen we're going to load
Tennis Wigan lower level
2
Let's go head in
That level 2 is added to a build
There we go that means we can load level 2 now
Play here
And see if it works
Let's go get a key
This game
I got the key here and avoid the enemy
Open it up and let's load level two
Perfect
Alright level 2 just loaded
That's awesome it's as you can see guys
We have a very simple game loop
Now we do have a problem if I collect 10 coins on other one
Entry level 2
The nearest Echoes back to 0
So we go to the next one here
It goes back to zero
Well
What if we wanted the player to be able to collect certain inventory items or maybe in
Is there a health or decrease their health or the amount of coins they have in take those stats
To the next level
Now sometimes in games like Donkey Kong you want everything to just disappear and you start fresh
On the next level I'm not really sure what you want for your game so I'm going to build out this tutorial
So that works for both
Permanent inventory
Taking out from one level to the other but also the ability to clear out that inventory if you want
Well if you recall inside of the new player
C sharp script all of our inventory is stored
Inside the script and includes the coins collected are hell my other items like that even
Our inventory dictionary so everything is stored inside of this script so the moment that
Load a new level it's going to destroy the player in the Script alongside of it so we need
To ensure that the player doesn't get destroyed when we load into a new level
We do that as we just go down the word start function here
In all we do is create a new line of code
That says don't destroy on load and then we just lost out this game object
Well that's great
That means that were not going to destroy the player but the problem is
If we load into a new level
There's a player in that level as well so that leaves us with two players
Another problem
So in order to ensure that we don't have two players
Once level 2 is loaded
Read actually destroy one player
That is not the original player right
So what we want to do is actually just jump into a new player script here
And let's see here maybe on start and we could say something like
If we find a game object
Cold player
Well we just destroy it
Let me explain your sounds right
50 magical find player
Then
We just destroy
Me I can't type today can I
Miracle
So basically what this means is that second player
Unravel 2
If we find a game object
Cold player meaning the original one that
Came into our new scene
Destroy Me destroy gameobject
Don't say that out in
Japan the level 2 and see if it works
Play I should be good right
Subtitled by -♪ online-courses.club ♪- We compress knowledge for you! https://t.me/joinchat/ailxpXoW3JVjYzQ1
Lips
Not good why is that
That's because it sounded self
So it destroyed itself
We definitely don't want that
This is also true for even level 1 if we go to level one
Viaplay
Destroy itself
Not good we don't want that
So how do we avoid this
Well what if we were able to rename the player
Say something like
Game object
That name
Equals new player
We Do It Like That
Will that work
Which shop in the unity in hip fly
Another one
Look we have a new name is called new player
But I think there's a problem here what is that
Well if we collect the key here grab the key
Jump into the new scene
Jokes that didn't work
Another boat named new player
So it's not actually gonna find anything called player in destroyed that
So here's what we need to do
We need to go ahead
And use a new function
Called a wake
This is unity's clever way of making things a little bit easier for us
Awake and start are basically the same
Assist awake cabins before start
It will always fire before start
I think about maybe you wake up for the day so you nearly was a person you hit play
He wakes up for the day
And then he starts ok so on wake
We need to search out
In find if there is a game object called new player I see this
But here
We're going to look and see if there is a game object called new player ok
What's that mean what the original player the one on level one
Is it a wake up
He's going to say
Is there a game object called new player in the scene
If there is
Destroy himself
Bad
Because were renaming
After awake
He doesn't have a chance to destroy itself
Ok
Another word the start function we remind ourselves
When we enter a new scene
The player I'm level 2
Will fire this when he wakes up
And he is going to find a new player
And he's going to destroy himself
Mercedes SLK play
And if it doesn't make sense guys that's ok
Because I'm going to go through it again just say it makes absolutely perfect sense
Outlook we are renamed to new player
It can be any name you want if you want to do player original or first player animal care but I'm going to
New player so it matches The Script
I've got my key was got a little to here
Perfect
Ok to look
Can you play a still there
Still got all of my inventory about 2 coins that's great
And
Noticed how there's no more player here
That player got destroyed
Because I cannot take a look at the Script
When the very first player on level 1
When he wakes up he immediately thinks is there anything called new player
Is there is anything called new player on this seen immediately destroy myself before doing anything
Else in The Script
I'm going to destroy myself
Because I'm not needed is already something out there called new player
Well
If it doesn't find anything cold new player
That means that this is the very first player
So I get a move on to the start function this is the next
Function that happens when you hit play
Just going to rename myself to new player
Ok I guess I'm the original player I'm gonna change my name it's going to be a new player
Then
When this player
Loads into a new scene
Another player in just for clarity here
Save this out
This player here
He's going to wake up
I'm awake
What you going to do
Is going to look for something called new player
Well
That old player from other one
He loaded into the scene his name is new player
Is the boss right he's in charge
Because
The level two player
Found that game object called new player
Bye-bye I get it I need to be destroyed
And none of it is going to fire
This ensures again two things guys
This ensures that the player doesn't get destroyed when loading into a new scene that's important because we want to save over
But it also ensures that we can test on level 2 if we want
Watch if we start a mobile 2 and a play
What happens
You just get renamed to new player
The means that he can go to another level he could take to clear the level 3
Causing level 3 player to destroy
Does that make sense
It doesn't recommend we watching this video it's definitely not a complicated subject
Not at all but it is weird and it's kind of abstract
You'll get the hang of it I promise
Now there's another problem here we will talk about in the next video
You notice that when we load into level 2 the camera doesn't know what to look at Bray
And also
The UI is confused
Show me the update those two things
So if we
Show battery level 2 in hip play here
You noticed the camera
Knows exactly what to follow
Because if we click on the virtual camera here
You can see follow is set to
Player
Because by the fault
We told it to
Before we hit play
Follow as a player
But if we load into level 2 from level 1
Remember because of the Script we just wrote
In the previous section
Destroying that target
So now
The camera
Has no idea what the follow
Because we destroyed the player associated would love to while entering this new player
So what we need to do is just basically tell this camera
Is virtual camera here
Right so we can actually do that with a new script
Ok so let's create a new script
Really call this
Scene
Camera
We don't want to call it just camera because honestly unity has stuff out of the box that uses the term
So seem camera
Just to make it a little bit more unique
To the cameras prefab and just drag
This new scene camera script
Under the main camera
The first thing I want to do is reference the virtual camera
Inside of this prefab
So what are we doing here
Generate
Serialised
Private
Virtual
Camera ok looks like we get cinemachine virtual camera look back
You really call it
Cinemachine
Camera
Alright
Sonos how it automatically add the namespace here
Using cinemachine
You don't see this
Go ahead and add this and that will allow us
Make changes
To the cinemachine virtual camera
Alright say that John back in the Unity
Inside of a camel's prefab hair ties
So what we can do is actually just
Drag
The virtual camera
To this for a slap here
And any cameras prefab we use without level 1 or level 2 is going to have this reference
So we can make adjustments
12 camera
From the scene camera script we have
Save that
What is double check and make sure it looks good
OK Google everything was great
What about level to take a look save that
Let's go to main camera here
Awesome
We have seen camera here as well and it's referencing its virtual camera
Awesome
What can we do now
We have access
Universal camera
What's double click on seeing camera here
I must think about something here
If
Inside of new player
Where destroying
That level 2 player
Doing it on a wig
Then technically if we do something in start
It's happening after a week right
So after we've destroyed that level 2 player
Then I guess what we can do inside a start with the right this pseudocode
Set
Cinemachine
Virtual can't type 400 camera
Target
To be the new player
How do we write that out with actual script
We could say
On start
Cinemachine virtual camera double click
Follow
And then all we got to do is set it to new player that instance
Transform
Let's make sure this works what it does will just do a quick recap
Everything
So let's hit play
And that start function is going to fire right now
And it's going to look for the new player instance there it is so
Change it change it still did The Script so it said it
To be
On the new player instant so kind of follow this
We could even just to show you
We could remove
This all together
So now it doesn't know what to follow but because we have that new script that happens on start when we hit play
It's going to find
The new player instance and start following
This loading a level 2 and see if it works
Perfect it does
Now it's actually it's not on the right side here because it's been confined
Be that polygon Cameron fighter
What it works
And that's exactly what we wanted
Just double check what exactly just happened
So here is the truth
When we immediately load into level 2
There's actually two instances of new player
So if this was inside of a wake and not start number awake happens before start
Is this was inside of a week
Unity with bow window what to do
Because it's inside a start in we've already destroyed
The level two player
Awake
Inside a start there's only one
Fire inserts
So we can immediately just said it to that player
The Masons guys I understand I know it a little bit confusing go ahead and watch this video again
Try and wrap your mind around
The sequence of events of what's happening
I got it and this is by far one of the most confusing part of making games and honestly I am
Working on the loading scenes portion of a game because there's kind of a lot of
Idiosyncrasies in weird sequences of events
For clarity here before we jump into actually changing the spawn location let's just
Quickly review with gone on here
So
The very first thing that happens in this game
At the very beginning when we hit play
We check and see if there's a game object called new player
Now
If you're starting on level 10 starting in any seen really and hitting the play button in the unity editor
There is nothing called new player
Why is that
Because immediately after this that's when we rename something to new player
Ok
To the very first player
You experienced this line of code but he won't destroy himself
Then we go to start and he'll just remind himself this is basically I'm saying I'm the boss and my name is new player
So when new player walks in the level 2
Level 2 player
He's going to destroy himself
Because he's not needed because the boss just came into the world
The guy who owns the game right
The protagonist the boss what do this level on said
I'm new player
You're not needed
Dad player on level to destroy himself
Therefore saving Oliver data from the original player from other one
Ok
And that's all because awake in Star happened at different times
Then we also created a script called seeing camera
And all were doing with this is were saying the moment that we start not awake but start
Start happens after a week
The moment we start
The game
I'm going to change
The follow target
Cinemachine virtual camera
To be
The new player instance
Now if we didn't destroy
Level two player and we had two instances of the player
Cinemachine would be very confused
Unfortunately
Because we destroy level 2 player in wake
Once we move on to start
He knows who to follow
It's important to note here guys
That's start
Doesn't have some kind of local sequence of events to see in camera
Start in a week in both scripts happen at the same time
So this awake script fires before this start and it fires before the start
It Moves onto this start here
And also the Script will run the start
Important to think of both of the start functions is happening in sequence after
Is awake
Function
I know that's confusing again this is not complicated
What is abstract in a bit weird so if this doesn't make sense I encourage you to watch this video just one more
Train wrap reminder around what's going on
The last thing we want to talk about when loading into a new scene is spawn sounds
We could just move the player around right and have him spawn here that sounds
What have you moved into level 2
You're moving a level 2
Is going to actually just stay exactly where he was in the previous scene
Does it play Now show you exactly what we're doing here
Ok
Salad
Take a look at the players current position
His position is Curley 18
60k 18 on the x-axis and 6 on the Y
If we run over here is a 20 up look
On the new level
He's at the same position
Unit 21
Nn6
Tell
You didn't respond and move
We really want him to move over here
That will be one of the spine
Tell the way you going to do this is
We could technically
Input values
Into a variable like a spawn position variable evektor to
But I find it easier actually just to create an empty gameobject
Call it
Spawn location
And then we can just move this
Around where we need the player to spawn
Somewhere about right here
Because they use this
On every single level
So now we have a game object called spawn location
We just go to our new player script
Are we going to do now is basically on start
See hear about right here we're just going to say transform that position = game on
That's fine
Is the average cased gamer bigger find spawn location
Transform
That position
So we're going to move the player
To the spawn location
That's great was straight out
Just for clarity here let's move the player somewhere kinda crazy so maybe like to put him at the 0 position
Just for cleanliness a crate
And he should spine
Three spawn location
Because we put that script
In the start function
Awesome
So he just Bond
Rayquaza spawn location was that's perfect
Well there's a problem though
Remember at the start function is going to happen one time when we start the game
So what we want to do is actually have this transformed at position
Equals to spawn location position we want this to happen after we load into the new seen as well
So how are you this footsie here
Well if we go to our
Simo Trigger
We definitely can put it here like this
Because we're outside of the new player script we need to make sure we reference new player that instance
Gameobject transform deposition
So now it's going to load the scene
Once you engage with the see no Trigger
And then I'm going to change the position of a player
In magic to the spine location
Of the next level
The thing is is that the moment we load a scene
Unity has to wait for this load to occur so literally the framerate will drop to zero until the
Scene is loaded in destroyed the Old scene
And then we're going to actually be able to find
The new spine location
Deposition the player
Balustrade
So first on start because of a new player script
It's going to send us to the spawn location again that's because of this right here
Any start functions of the new player script
And then when we get the key and go to the next level
He gets repositioned
Perfect
That's awesome everything wants to be working just fine now your notice we have
Some references issues here so we're going to address those in the next section
However
I want to make something Clear here
If we take a look
At the scene won't trigger we have this right here
This is actually a little bit redundant because
Pretty much doing the same thing in this script as well
So how can we make this a little bit cleaner
When we create a function
And call it
Public void set spawn position and replace inside of a new player script
Ok
And then we can just literally
Have the position change
Finding a spawn location
That way all we got to do is take this appear
In the start function set spawn position
Going to call that function for us
Do the same thing here as well
Make sure you do new player that instance
Set spawn position
The reason why we doing that guys if we ever wanted to change something about how a spawn a curse so for example
We wanted to animal play a sound effect we can go
No audio source won't talk about audio in another episode audiosource stop play sound
Spawn sound you know
If you wanted to do that we can just do a once in this function
NN
Anytime we set the spawn position of the player weather is on start appear
Or whether it's
Not occurring AC mode Trigger
Will have to write that twice
It's just referencing that one function
And also guys miss you open up the collectible script here and
We're gonna simply change this from collision gameobject name to remove this in with just going to simply
Use the Instance of the new player so new player
Instance Die game object
Here we go
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.