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
Are you ready to make the sword kill some enemies
Let's get into it that sounds fun
Alright so I'm going to open up one of my enemies
Is here or dizzy and my seeing red
And
I'm going to go out
Add a
Area
Area2d note
Is is it essentially a way of detecting collisions
They are essentially
Trigger's
So you can imagine that
Kind of two different types of curls
Is the types of collisions that will make
Character stop when they hit something but then there is the type of collisions like hitbox
Which are basically just detections of weather
To take down
Very rarely and James does it actually
When a fact
On your characters ability
To move
So
Rebecca going to be setting up this area to use which are going to act as Trigger's
That we can listen to
So that we know when
Destroy the enemy or deals
Do the player and so on and so forth
So I've got my area today
We need to match like the character body 2
Subtitled by online-courses.club We compress knowledge for you!
Add a collision
2D
The child 2
And what I'm going to do as I'm going to create a new circle
In that
And it's generally a good idea
To make your
Hitbox and hurt back
Sizes
Biased in the players favour
So that means when you're creating a heart box for an enemy
You want to make the heart box larger
Then
The enemies
So I'm going to
12
I'm going to you
The move to all by hitting w
I'm just going to move it up until it's about Sam
And I end up with a position of -5
In the
You can see how this area is much bigger than the Vision
And that's actually a good thing because we want to
To be
For giving to the player to some extent so it the game field
Really fun and
Smooth and not super Pig
And I'm going to move this area to d
To the first
Child
The character
You too dear
And that would change the draw order
Such that
That area is now behind
So that we can see it better
So we do need to configure
The collision layer in the collision mass
Remember how we did
4
The player in the air
Character body 2
Because we didn't
1 to 10 to count as terrain
We want them to only look for today
Act as two
Give me the same deal here now before we configure the collision layer in the collision
Let's go to Prague
Project set
Let's go ahead and scroll down until we see
The layer names section
And then click to die for
R32 physics layers
And what does tool allows us to do a w b settings allowed to do is provide names from his lair so we're not referencing
Buy number
And forgetting
How are using all the layers in our game
My middle name Leah one
I'm going to name layer two player
I'm going to name
Layers
Anime
Close app
Hover over these lair B here
You can see that it'll tell me
This is the terrain layer
This is the player
That's very heavy
So what we're going to want to happen
Is
The abilities at the player cast
Are going to be
In a lair
Dad the enemy
I will look for
So again the layer is where does this collision exist what layer does the
Existing
And the mask is
Which layer
Am I looking for
4k
This case we're going to set the enemies
Collision layer
20
I'm going to set up enemies collision
2
Anime
So essentially what this is saying is this the same
This area to do
Is going to look
Any collision
That exist
In the lair
Anime
No I know that can be a little bit confused
And you might be thinking what does it make more sense to put the enemy in the layer
And then make the ability the thing that scans for the
And I would say that yes that does make more logical sense but that's not going to work and the reason is because
We cannot detect collisions from an area 2D
If it's
Existing in the
We have to actually be looking
With the mask to get
Detection
I know that's a little bit hard but basically you can envision later as being a passive
Part of the collision and mask is the act
So the weather is just saying
Hey other things in the game I'm on the Slayers
Can to live with me
And the mask you're saying
Hey other things in the game I want to see if I'm colliding
I think that's pretty clear you can read the documentation
Collision
There is quite a bit
It might help but we're going to move on so I've sent this to be on the enemy mask and no layers
And now what we're going to do is we're going to go to the sword
And we're going to do the same thing so go ahead and create a new area too
By hitting control a or a right click
And then add a child node of collision shape 2D
Just like weed
In this case I'm going to set my ship
To be
New rectangle shape
Today 11 in today
I'm going to set the size
230
30
Something that looks a little bit alright first I'm going to grab this
Colours and shape I'm going to select the move to
And then I'm going to move it over
Until the left edge of the
What is a line
Through the centre of
Now I am I
Because this is going to give the sword a direction
In terms of wish
The tackle
So animation
If I play the animation here
Attacking in this area
So I'm moving the hip-hop so that it encompasses roughly
That
Swing anime
Area
And again it's ok if your collision box is larger than the visuals that actually preferred
Because it make
Feel better
Another benefit of doing this is that when we rotate the song
With the rotate tool website
Concealable hitbox
Automatically aligns itself in the door
So simply by
Rotating the root node
Everything will follow
And it will be
Paul
Good so let's go ahead and open up the animation player
And you can again make sure that the animation tab is high
At the bottom
Select the swing animation
And
Let's zoom in a little bit with the
Mental on a bottom
So we want to start
Hitbox of
Disable
Because there is a small wind-up toy
Animation
I'm going to select the collision shape to
I'm going to go down to the disabled proper
I'm going to cry
On so distant grey which means that it's not
Is it going to do
And I'm going to collect the key
And then
Create
And so that will start off
Disabled
Play Mission starts
I'm going to scrub forward until the sword starts attack
Which is sad
2 seconds
I'm going to insert a key at this
Position in the timeline
And then I'm going to click on Nike and under
You can see now if I scrub through
As soon as it hits point to it becomes unable to
I'm going to leave enabled until
For and then I'm going to write
Honour disable track
Insert
Mcconnachie frame and
Essentially what we're going to see it
Is startup disabled it becomes a neighbour
4.2 seconds
The duration of the sword swing
And it is disabled
So doing this point to second windows when it will be
Detect
What's click on the area2d mode in Arsene dark here
And then scroll down to the collision layer collision mask setting
This is going to be the opposite of what we are doing for the end
We want this to
Passively in a lair
So we're going to answer
The train bit and turn on
And we actually don't want to be active
Looking for or listen
Any colour
So I'm going to turn the mask off
Ok
So there is one final thing to do which is that we actually need to handle these
Because decorations are being detected but nothing is being done
So I'm going to go back to my basic
I'm going to click on the Script icon to open up the Script
NRG
Shove the animation draw back down so
PC World
And
In here
Very similar to how we connected to the timer within a connect to the area
So if you click on the area too
And you go to the Note Tab
You can see that
Here are all of our area 2D signals listed right here
The Wonder interested in his area
Which is going to as it says
Omit
When they received area
This area
So we're going to go out on Saturday
So in our base Academy Script I'm going to replace the pass
In the Rain method with
Dollar sign area two
What again is shorthand for getnode area 2
Dad
Area entered
Which is the signal name
On
Price to find an area entered function by 2
Funk
On area
And you have to be very careful when you're connecting to signal
Because
Some of them pass arguments so in this example
Area entered is passing in an area 2D
As an argument so we need to actually accept that some Guinness call other area
Area2d
And then a colon at the end
And what we going to do in here or just going to for now
Too cute
So this is the same method that we called from the animation player in the sword ability
From code this time and what this is going to do as a refresher is this is going to at the appropriate
Time
The Entity from memory and remove it from the sea
Not not order it'll be removed from
And then
Read from net
If we did everything correctly we should be able to run the game in sea there
Enemies will start
Subtitled by online-courses.club We compress knowledge for you!
Being destroyed
So you can see
When a collides the enemy will be destroyed now we can see this a little bit better
If we go to
De Bogota
And turn on visible collision
Never Run the game again
Now we can see all of the blue collision
And we can even see the sword
When the sword part of you can see that there is a l
Blue Square
So is one problem still
Which is that the sword is not being angled toward the end
So I can only hit the anime if it's facing a very specific Direct
Answer the way that we're going to fix
Is we're going to go back to the sword ability
Controller
So control shift open your quick access
Look for the sword ability controller open
And you can open up the script with the Script
So here's are on time or time
You can see that
Getting
It's been spun at the my position however
Is that being angle
Taured
So how we can do
What we can do is weekend crab the direction vector
Between
The enemy Anderson
So let's say via enemy Direction
Is equal to
Let's grab
Enemies
Global position
Miners
Sword
Global
And remember
When you're doing that
Subtraction to get the direction between two points
The
Position that you want to Vector point
Should come
So we're basically take the enemy position at that enemy position from
The Sword in
Global position and then we can say sword instance
Rotation
Is equal to
Enemy Direction
So this is saying is this is same get the angle of that fact
That represents the direction from the sword
To the edge
And then set the swords rotation
This rotation is in radians
That's fine because this duck angle Returns
So let's go back to the game and see if that works
And funny thing is there
This technically works but it's not working because
The enemy position and the sword position are exactly the same
So one thing we can do as we can do
Set a sword position to be in a random radius away
From the edge
So let's go ahead and give the sword a little bit of a random offset so we're going to say
London
Weather assigning global position of the sword where they say
Sword in stone
Dan global position
Plus equal
We're going
Take a
Right
Vector
We're gonna rotate
Bye
Something between Llandaff range
I'm really go from 0
2
And this my brother will be confusing but basically remember a vector to that right
Has a rotation of 0
We're going to take that within a rotated
Buy anywhere from 0 to 2pi since when radiant so this is the same as
Randomise the rotation of this vector
From 0 to 360 degree
Tau is just a constant that represents to pi
So that we don't have to write tutor
So that's going to be our rotation and then we're going to give it some offset so we're gonna x let's safe
So saying
A vector that points in a random Direction so this is a unit vector that points in a random Direction X
Pixels in so now the sword is going to spawn anywhere along a circle
That is represented
Buy a radius of 4 around the enemy
Hopefully that makes sense
But now that we've offered the global position buy it for pixels
This Direct
Should be
Good
The sword is actually rooting it
Of course there's not enough enemies to exactly see what's going on
I'm going to pop over to our main scene
And duplicate the enemy again
And then use w to move it around
I'm going to do another one
Duplicate another one
Basically just put as many enemies
You want
In your lover
What's going on run it now
I'll give you a ring
Opportune
Play the test and
Can you can you go to sort can actually attack multiple enemies which is good because
Games like this
Like vampire survivors
And other games and leisure
Do you have abilities that
Hit multiple enemies
Much more work to be done as it relates to abilities and combat
But
We've got the foundation in place
For future
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.