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
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
Russian
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
We've got viles in place and we've got
Experience being counted based on the files that you've picked up
Missing is the ability of the enemies to drop The Voice
And so we're going to do that and we're going to do that in a manner
That allows us to
Easily added functionality to future and
That we might add to our game
And so what we're going to be doing this for going to you
A technique known as
Composition
Composition is essentially what we've been doing with the native good all
We take us
Of a bunch of different types of nose
So for instance if I go to my place
We have a bunch of different types of notes
And all of these notes
I have distinct functionality
What together
They composed
The player
And so we're going to be doing something similar
With our own notes and what we're going to do
Is were going
Create a
Subtitled by online-courses.club We compress knowledge for you!
Vial drop composed
And the vile drug component will be able to listen for
When the anime dies
And then spawn a Vial at
If a certain
Threshold is met
But before we do that we want to implement
Health component first
Set the volume drop comp
You can listen for
So let's go out and create a health component and that will allow us to create
The concept of health as well
So let's create a new note control
Click on other node
Make this note a
Play Oldham
Let's call this health
Component
What's 8
Save it into seems and then let's create a new folder
Call the component
And let's see
The health component in there
Search go ahead in Addiscombe
And the default settings are
I'm going to add an export variable at the top
At export
Bar
Max underscore health
And we can just said it we can initialise it to something like
So now you can see that our health component has a Max health property
That we can add it through the inspect
Ok so what kind of functionality does a health component
Really clear out of these functions and we're going to write a new function
Funk
Damage
And then we're going to take a damage parameter which is going to be a Flo
And we need to subtract
The current health
Based on the damage that's coming
So let's just right past
An up blow
The max health export variable
Let's do another variable called current
Can we actually do need that ready method so let's go ahead and and that ready
The back in
So far
Underscore Reading
Really just say current health is equal to Max health
Henry
Perfect
So when we damage
The Entity
We need to
Current health
And subtract with Myers
The damage
Now
We actually don't want to help to be negative
A more appropriate way to do this
Might be something like
Current
Equal
Max
Current health
-10
And 0
So Max takes the maximum
Value of the two supplies
And this case if we ever end up with a negative
When we take
The damage being passed in away from the current
The maximum value becomes zero
This is essentially in forcing that we never dropped below 0 for a curry
Then we can do as we can
F
Current health
Is equal to Z
Then what we need to
We need to die
However
We don't really have anything
Hear that control
The death so what we're going to do is we're going to create a custom signal above the export variable
So signal
Dad
And then when our current health equals
What we can do as we can do
Died
Just like some so again this is just going to notify anything at listening that we've died
And you talking to
We're going to use
Start q
So what is this
It's a little bit
Tricky to explain
Owner is the note
That constitutes the route
Are the scene that this notice
So
In this scene in my help component seen my owner is Noor
My owner is no
Why because there's health component is the root of it scene
So it doesn't have an owner there's nothing at all
If I were to add what's a Sprite 2D as a child
This spray
2DS owner
Is the help
Right
Let's take a look at it
My player
Buy players area2d
Has an owner that is equal to
The player
Does not have an hour
So when we go to a basic enemy so I'm going to control shift go and open up the basic anyway
When I instantiated
The health component which you should do this as well so go ahead and stay and she a health camp
Space Academy
With ctrl shift a
Lights on
This health component now has an owner
What is basically
So we'll look at that script
What is doing moana Q3
Ordered IQ free
Breeze
The scene
But this helps
Belong
That will probably move this at some point
Out of this
Will it make sense for an hour to put this functionality in the
Component
So let's go to a basic anime Script so open up the basic anime scene and click on the Script icon
So we have this on area enter
Instead of calling q-free we actually went to apply damage to the
So let's go up blower max speed and Let's Get It On red
Reference
To the health care
So I'm ready for health compare
Is equal to dollar sign
And what we can do if we can go to your health component script again
And underneath the note we can write
Class underscore name
Health
Combine
And this will allow us to cast
Things to the health
Component
Type which will give us the Intelligence we need
Order code suggestions we
2 for example use damage ankle
To the Dead Sea
Go back to my basic enemies
And I'm going to type this health component as a type of
Health compare
Perfect and so now in the area entered I'm just going to do something very
Health
Start
Damage
And let's just go ahead and put 100 in
Remove the Q3 from the basic anime and using the health component
No obviously we're not getting any damage
From
The other
Area
And that's fine
We won't work on abilities transferring damage in
Future
Ok so we should basically see no functional chair
When we're on the
So what's going on
Ok so the sword appears and Still Kill
The rat
Ok so that's looking great
Warning me about the local function parameter
Damage shadowing and
The problem is that I have
A function called damage and the parameter is called damage as well
And that can be a problem because if I were a cold damage again in this function
It might be ambiguous as to what I'm afraid
So I'm going to do instead as I'm going to rename this damage
Parameter to damage amount so if you highlight this damage
And then press control d
That will highlight the second instance of damage that
Using here that I was going to write damage underscore
And that should be just
Ok so we've got the health component can figure
And obviously we can go to our enemy here and we can change the amount of health
That the enemy has just threw the editor here
Incel
Windows health component build
We can now add this health component to any entity we want to have
And it becomes a nice reusable
Piece of coal
This is composite
We're going to use this whole component
All over the place
Broad kinds of purpose
And we don't need to keep writing the same code over now
So what the hell come on built let's ride a vile drop components
Let's head control m
Same deal make this a
Basic notes
Cotton voile
Drop
Compound
So let's go ahead and save
And I just can't Vale drop and it will put it right next to the
Let's go ahead and Addiscombe
What we're going to do this time
Is we're going to
We're going to turn off the 10
So we don't want to have the ready method and process method to find first anymore
We have a good grasp of scripting sword just going to cry
Andover going to get is the extend no
Witches
Perfectly
The veiled wrap component what do we need well we need a reference to the vile seem so
Go ahead and right at export
Via
Underscores theme
That's going to be of time
Vaccine
Let's override the ready function
And what are we going to do in this
Function
Well we actually need a reference
To the health camp
As well
Solicitors Right pass in our ready method here
Just read it doesn't error
What's create another export variable
I'm going to create
Health composed
No
Just like so
So what that's going to do is that going to Louth
Supply
The health component path in the edge
And then I'm ready what we can do
Is we can say
Health component
Health
Component
Animal parenthesized
Where is a guide which is the Sydney
Dartconnect
Subtitled by online-courses.club We compress knowledge for you!
On
Dad
So it's that simple and then we're going to go
Endive
And what we want to do on death well we want to do a check
Vale seen is equal to null
Then we're just going to return out of there
Because We Can
Device is not defined
So what are we going to do we want to spawn the vile at the position of
Enemy
And
The veil drop component is going to be another note alongside the health component so we can use the owner again
To grab the
Now this is a little
Unsafe because we're not guaranteed
The owner is going to be a note today
So we could write a check we can say
Moana
Is not
No time to die
Then we can return
And I've got this order of the is not reverse the little bit not has to come first so if not owner
Is no to die
Then we're going to return which means that if we make it past that then our owner is entitled to
And so what I can do is I can save our
Spawn position
Is eagle
Moana
Parentheses first
Moana
As notary
Dart global
Perfect select response position
Then we're going to take
The vile seem so we're gonna
Instantiate that's all say vile
Incidence is equal to
Vial seen.in stands
Again we should
Instantiate as a node to use
We get the
Proper intelligence
Animal going to take the owner
Get pair
So we're going to
Princess adda
As a child
To the parent of the owner
Get parent and Child
Violin strings
And I'm going to say
While instance global position
Sequel to spawn
Position
Perfect solicitor are basically
And let instantiation
A child seen underneath
And we're going to instantiate the file drop company
And we're going to put it right next to the health component in the tree here
And now let's sign the health compare
In the health component property
But we're not going to assign the vile scene
We actually want to assign the vile scene within the veil drop component itself
So open up the volume drop compose
Search your filesystem
4
Experience vile
And go ahead and drag it over to the vile
So now we go back to our basic enemy
You can see when I hover over the vile
Component
That's vile scene
So now whenever we instantiate the valve
Component the only thing that will need to be said is the health component which will 0.2
The local
Self composed
Ok let's go back to our main
Delete all of these experiences while so holdship
And click
The first one in last one
Delete all of them by pressing delete
And then let's go ahead and Run the game
And so as these things die they should drop vials
Perfect
So there's one Vial
Now
We're getting a couple of hours here
Ok
So here is another quote
Adele
If you look at your errors you'll see can't change state while flushing
Queries
And this is because
We're trying to freeze something that is in the middle
Handling collisions
That's just a good ol' Cork
I'm not sure exactly why
What is the case but the way that we get around that area
Is we actually need to use
Call
Deferred
And what deferred calling does is it wait until the idle frame to call
Sophie got oral health component here
Are we going to do
Is we are going to create a new function
Card check underscore death in our health and
We're going to take this if current health is a good as your work I take that out and
Underneath that checked
Does the check that function body
And any here what we're gonna do we're gonna use
Callable
So capital city
This is 8
Callable
And then in parentheses were going to put in a reference to check DAF now your autocomplete is
I want to automatically call it
Why using parentheses we don't want that
So remove those parentheses
They should just be passing a reference to the function in the collarbone
And then we can do
Call deferred
So that's going to do that going to take this function
And then call it on the next I don't
And then
We're going to do the check that function at that point and then we can
Handle all the stuff for handling so it's going round the game again
That should no longer be
And we can see that vials were being spun
And I can go ahead and pick them up
So one final thing to do before we wrap up this lesson which I know is a little bit longer than the other
Is Rihanna add a drop percentage
Answer to the vile
Insole let's go ahead and go back to eval component script
As the first export variable
What's actually reorder some things let's move the pack scene
Blow everything so
Use alt and down on your keyboard to move that line down
And then the first export is going to be
Port Vale
Flower
No
Are we actually do instead of just a plain old export as we can do export underscore range
And then we can in parentheses
Define what the range
So we can say 0 as the men
And one of the max
So if we go to avail drop component over on the left
We can see a drop percent in it cannot exceed 1
And it cannot go below zero
So this is nice because it doesn't make sense to have a more than 100% or less than 0%
Strawberry
Perfect an elastic that we're going to do with the Val drop is we're just going to say
Initially to
What's a .5
So I'll have a 50% drop rate by The Fall
That will be configurable
And the reason that you might want to set a default variable in your exports is because if I go over 2
Just represent in I
Dragon
You can see that this little arrow appears
When it's not
When the values are equal to its default
And that's nice because now I can just click the arrow to reset it
To what I've got hardcore
Industry
So if you want to just provide some sensible defaults for anything that your export
That's all
Hindi to do
So now we need to take into account that drop
Percent
Right
So
What we can do it simply is we can just say if
Ran
Surround f Returns
Every you can control click into things by the way so I hold ctrl and click in taranto
That will take me right to the documentation for
And that
Says it return the floating-point value between 0 and 1
So
It's going to be very
To do what we need to do
We can just say if Randolph is a functions on Vulcan
Is less than or equal to
Drop percent
Actually it's not do that let's say if friend of is greater than 8%
Return
So basically
F r and F is not within the range of 0 to drop
Percent
Then we're just going to return outlet
Ok so now for you run the game in test that we should see that roughly half the enemies drop vials when they die
So that one drop
That one day
That one
That one
One of them
So it looks to be working
Ok so that was an introduction to components we've now got a health component and a vile drop component that we can use toucan
Play your game as we continue
Into the future
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.