Let's create the fire trap and other traps.
To do that, I'm gonna head over to my project tab assets and then sprites folder.
Then I will head over to my Pixel Adventure folder.
And then we have.
As you can see, we have the source by Cat, spike Ball and spikes.
So I'm gonna find the fire one.
So I have it over here as you can notice.
So what we're going to do we're going to make the animation.
So basically let's select that sprite sheet.
Let's click on this open sprite editor.
And let's choose this sprite mode to multiple pixel per unit to 16 and filter mode to point no filter.
Let's click on this apply button and let's slice it off.
Slice it create pixel count instead of or automatic.
So let's click on this slice.
Or let's select automatic to create by cell count.
And let's spawn for four columns and one row.
So let's put four columns and one row then slice and then apply.
And let's select the game view right over here.
And let's move over to that sprite sheet.
Let's click on this arrow.
And in order to see the individual.
So let's select any of them.
Let's select the first one and let's drag it over to this in view or into this hierarchy.
And let's call this one fire.
Sorry.
We're going to call this one fire.
So let's go over to Inspector.
The inspector let's rename it to Fire Trap or let's simply call it fire.
And we need to make the animation.
But before we make the animation, let's add some components to this fire game object.
First thing I'm going to add a rigid body 2D.
And this one it's going to be a little bit different.
Basically what we will do I'm going to show you let's select the fire GameObject in the hierarchy.
First let's drag it in the top so we can see all the time.
And let's select the Fire Game object.
Let's click on Add Component and I'm going to add the rigid body Rigidbody 2D.
So let's find that by typing rigidbody 2D.
Let's go go over to Rigidbody 2D.
And we're going to set the body type to kinematic.
So it's not going to fall down.
It's we're going to do it a little bit different.
So that's why.
And collision detection we're going to choose continuous and interpolate to interpolate.
And after doing that let's add up the box Collider 2D.
And if you just want to skip the part which is interpolate, you can just leave it as none.
Or to make it a little bit smooth, you can choose interpolate to interpolate in your rigidbody 2D component.
And we're going to add a box Collider 2D.
So let's click on this add component and we're going to add a box Collider 2D.
And let's click on this Edit Collider Edit Collider.
And we're going to edit the Collider as the size of our sprite, size of our sprite.
And inside this box Collider 2D.
What we're going to do we're going to check this is trigger.
So it's this box.
Sorry.
This fire game object.
Just going to check with trigger.
And it's not going to register our player to pass through it.
And let me show you and let's assign this, uh, fire uh, fire trap game object as a trap tag.
So let's go over to Inspector Attack.
As you can see it says untag.
So let's assign with trap.
And if we just go ahead and then play a play, hit this play button in the top.
We can easily notice our player game object.
Just gonna able to pass through this fire, uh, fire trap because we just check the trigger to true.
So that's why it's gonna check with trigger, and it's not gonna register our player to pass through
it.
So let's have a look.
So if I just pass through it, as you can see, we simply able to pass through it.
And it's not registering our player to pass through as you can notice.
So let's get out of play mode and let's make the animation first one.
It will be ideal.
It's gonna play something like up down, up, down.
And the second one, second animation clip will be a flaming like fire flame.
And if, if, if that moment our player game player game object trigger with that, then we're gonna
destroy our player.
So let's make the idle, uh, idle animation clip of this fire first.
So let's go over to that spritesheet.
Let's select all of them by holding down shift, and let's drag it on top of this fire GameObject in
the hierarchy.
And we're gonna move over to the assets folder.
And in assets folder we have the animation folder.
So let's open that up then drops animation folder.
And we're going to call this animation to something like fire idle uh fire idle idle something like
that.
And let's click on the save button.
And if we choose our fire GameObject in the hierarchy, then move over to animation tab and then click
on this play button.
As you can see it just playing that animation clip.
And the second animation clip will be the filming of This fire.
So we're gonna do that.
So to do that, let's head over to our project app.
And now we're going to select the Spritesheet which is the fire.
So let's select that.
Go over to Inspector and what we're going to do.
We're going to choose uh sorry sprite mode two.
We're gonna leave it multiple and pixel per unit.
We're going to choose 1616 and filter mode to.
We're gonna choose 0.0 filter point, no filter.
And let's click on this apply button in the bottom right.
You can see and what we're gonna do now and we have done a mistake.
The mistake is that we assign it this a fire game object as a fire tag.
And we don't need to do it because, uh, we just want to, uh, just gonna be a little bit different.
So that's why.
So.
So let's leave that, like, uh, let's leave it.
I'm gonna explain it later.
So let's select the fires sprite sheet.
Go.
Go over to Inspector, click on Open Sprite Editor and instead of slicing automatic we're gonna slice
individually.
So let's click on this slice.
And we're going to choose automatic to create by cell count.
And we have three columns and one row.
So we're going to put three columns and one row.
And then click on this slice.
And then click on this apply button.
And let's select the game view.
Once again over here.
Let's go over to that spreadsheet.
Let's click on this arrow.
And we're going to select all of them by holding down shift.
And then drag it over to top of this fire game object in the hierarchy in order to make the animation
right away.
So let's go to Assets Animation folder traps animation folder.
And we're going to call this animation clip to something like fire underscore flaming air flaming something
like that.
And if I misspelling that I really apologize I really apologize, I don't know the correct spelling
of it.
I really apologize for that.
But you can just name it to something like Fire Trigger.
So I'm going to call it fire Trigger instead of Fire Flaming.
So I'm going to call it Fire Trigger.
And let's click on the save button.
And now if we select our fire game object move over to animation tab.
And then click over here.
And then choose this fire trigger.
And then click on this play button.
As you can see this animation clip just playing over again and again.
And what we're gonna do, we're gonna add a box collider to the over here as well.
Or a Circle Collider 2D or a Polygon Collider 2D, something like that.
We're going to add that.
So the player game objects knows this is our fire and it's gonna trigger with that.
So we just want to our player to destroy.
So that is the thing.
So we're gonna add a component as well.
So let's add another component to this fire game object.
And that will be a Polygon Collider 2D to just fit this flame perfectly.
So that's why.
So let's click on this add component in the inspector.
And we're going to add a Polygon Collider 2D in order to match up perfectly.
And let's click on this Edit Collider.
And you can just edit the collider as the size of your flame.
Like that.
Like this.
As you can notice, and this seems pretty much fine.
Let's do that.
And this seems pretty much cool.
And what we need to do now, we also need to check this is trigger.
So we're just gonna able to pass through it easily.
And we're gonna what we're gonna do we're gonna disable our uh, box Collider 2D box Collider 2D and
this polygon Collider 2D, Polygon Collider 2D.
But we're gonna enable once, uh, once basically this this fire game objects plays the, uh, play
the, uh, fire flaming animation clip.
And if we select our fire GameObject in the hierarchy, then move over to animator tab and you will
see.
As you can notice, right over here we have the fire idle and we have the fire trigger.
As you can notice that.
So when I create a script in order to basically uh, to do that basically enable our box Collider 2D
or this polygon collider to uh, 2D as well.
We can create a script in the start of the game, we're just gonna disable.
And once this player game object just gonna, uh, place this, uh, animation clip, we want to enable
our box collider 2D, so we don't need to create a script to do it.
Instead, we can just do it, uh, in our animation tab so we can simply select our fire game object,
then go over to Inspector and uncheck this box Collider 2D as well as Polygon Collider 2D.
So it's not gonna detect any collision.
And once it's, uh, gonna play the fire flaming animation clip.
Then we're gonna enable this box Collider 2D as well as this Polygon Collider 2D to check if this if
our player just trigger it with this fire game or fire trap or not.
So we're gonna do that.
So to do it we're going to select our fire GameObject in the hierarchy.
Then move over to animation tab and then choose this from Fire Idle to Fire Trigger.
And make sure you just click on this red button in order to basically, uh, to capture the animation.
And in this animation what we want, we want to enable our box Collider 2D as well as Polygon Collider
2D.
So it's gonna check the trigger what we trigger it with.
So let's click on this box Collider 2D.
Basically we just enabling that as as well.
We're gonna enable our Polygon Collider 2D and end of the animation.
Or we're gonna disable that something over here we're gonna disable.
So let's uh, do that.
But before I do I'm going to copy this, uh, frames.
Uh.
Copy this frame.
Sorry.
Uh, I'm going to copy this frame by Ctrl c.
Sorry.
It's not going to be control.
It's going to be Ctrl C and let's scroll.
You can scroll your mouse to zoom in and zoom out in your animation tab.
And make sure you just click on this red button to capture your animation.
Else it's not going to capture.
So I'm going to move it something over here, and I'm going to press Ctrl V on my keyboard in order
to paste it.
And if we go ahead and then click on this, uh click on this play button.
We can see the animation and we just enable it our box Collider 2D as well as Polygon Collider 2D in
Inspector as you can notice.
And we can just go ahead one more something over here and we can just press down Ctrl V one more time
to paste our keyframes.
So you can simply simply select like this.
And you can press down Ctrl C to copy.
And you can just move a little bit, uh, more frame, and then you can simply press down control V
in order to paste your frames.
And now as you can see, it's done.
And at the end of this animation clip I want to disable the box Collider 2D as well as the Polygon Collider
2D.
So I'm going to go over to Inspector.
I'm going to uncheck the box Collider 2D as well as the Polygon Collider 2D.
Since this animation completes just a completely plate.
As you can see at the end of our animation clip, we just disable it.
So once we are satisfied, so then we can just click on this red button to capture the animation.
Or we can just leave it like that.
It's automatically just going to capture the animation.
And I'm going to move over to now Fire Idle.
So let's select make sure you select your fire GameObject in the hierarchy.
Then move over to animation tab.
And then you can just choose the animation clip right over here.
So from this fire trigger we're going to choose the Fire idle.
And we're going to copy this frames and we're going to paste it, uh, something over here.
We just want for two second to play this animation clip which is the fire idle.
So that's why.
So firstly what we need to do we basically need to copy uh copy this frame.
Also we need to click on this red button to capture the animation.
Else it's not going to do at all.
So we're going to select this.
And let's press down Ctrl C to just do it.
And let's paste it over here by Ctrl V.
And let's move it somewhere around here.
And we're going to select all of this by Ctrl C.
Let's press down and let's move it somewhere over here.
Let's press down Ctrl V and we can just move over more frames.
Something over here.
Let's press down Ctrl v.
Uh so as you can notice sorry uh this seems pretty much fine.
So we can just click on this red button.
And once you are satisfied then you can just click on this red button to capture the animation.
So if I just go ahead and then click on this play button in the top, you will notice that this, uh,
this Firetrap game object, it's just going to play the idle animation clip over a again and again.
And we also need to play the fire trigger animation or the fire flame as you can notice.
So after some period of time we also need to play the trigger animation basically this fire trigger.
So we're going to get out of play mode.
And what we can simply do, we can just right click on this fire idle, but make sure you select your
fire game object in a hierarchy.
Then move over to animator tab.
Right click on it, make Transition to Fire Trigger and then select this transition.
Go over to Inspector and we're going to leave the has exit time because we want to play the complete
idle animation clip of this fire uh fire.
So that's why and exit time we're going to put one.
One basically means 100%.
And we're going to choose transition duration to zero.
And if we scroll down, we can choose a condition in which condition we want to play that animation
clip.
So we don't want to play, uh, we don't want to choose any condition and we just automatically want
this, uh, want this to play the fire flame animation clip.
So that's why we're gonna not gonna choose any condition.
So basically means after playing the fire idle animation clip of this fire game object 100%, it's gonna
play the fire trigger or the fire flame.
So if we just go ahead and then click on this play button in the top, you will able to notice that.
So just wait a moment.
And once our, uh, compilation is done, basically once we start our game, we're gonna notice that.
So just wait a moment and you will see.
And we can see indeed it's now playing the fire trigger.
And we also want to play the fire idle as well.
After playing the fire flame or fire trigger animation clip 100%.
So I'm going to get out of play mode.
So we also need to play this via idle.
So we're going to right click on this fire trigger.
Let's make a transition back to our fire idle.
And we're going to select the back transition.
Then go over to Inspector.
And we're going to leave the hash exit time because we want to play the fire trigger animation clip.
And and we're going to fire trigger or the fire flame and exit time, I'm going to do one basically
means 100%.
And after playing 100%, we just want to move over to this fire idle.
So we're going to set the transition duration to zero.
So we immediately want to play the fire idle once we play it our fire flaming or the fire trigger animation
clip 100%.
And if we scroll down we can choose a condition in which condition we just want to play.
And since we don't want any condition, we don't want to choose any condition and we just auto automatically
want this fire game object to play the fire idle and the fire trigger.
So that's why we're not going to choose any condition basically means it's going to play this fire trigger
animation clip 100%.
And once the animation is over, basically played 100%, it's going to play the fire idle automatically.
Fire idle animation clip automatically, and you can just check that out.
So if I just go ahead and then click on this play button, you will be able to notice that.
So just wait a moment and you will see.
So basically the fire trigger and the fire idle animation just gonna play automatically.
Uh, as we have done.
And we just made the fire idle 100%.
We can see it's played.
And after it's played, the fire flaming, we can notice that it's playing the fire idle.
But once, uh, if I select my fire GameObject in the hierarchy, you will be able to notice.
Once we playing this fire idle, we can see in Inspector, uh, we just disabling the box Collider 2D.
But once we playing the fire uh, fire flaming or the fire trigger.
We can notice in the inspector this box collider 2D as well as this polygon Collider 2D just getting
enabled.
So we can just check the trigger.
Trigger basically means if we trigger with this player game object.
So what it's basically means need to do.
Basically we just want to damage our player once it's going to play the fire.
Uh, you can simply say the fire uh, flaming animation clip.
So I hope you get the idea that how you can do it and make sure you just go over to Inspector, you
assign this fire game object as a fire trap, a trap tag right over here.
As you can notice in Inspector.
So I'm going to get out of play mode and let's make this fire game object a prefab as well.
So we're going to have the copy of it.
So I'm going to move over to my project tab.
And then I will head over to my assets folder, then prefabs folder.
And let's select this fire GameObject in the hierarchy.
And let's drag it over to this prefabs folder and let's create another subfolder for our traps.
So let's right click then create uh create folder.
And we're going to name this folder to something like traps folder.
So let's call it traps.
And we're going to select our type traps.
So let's hold down Ctrl on our keyboard.
And we can choose our source pick head and this shore and this fire.
And let's drag it over to that traps sub folder.
As you can see to just keep our project in organized way, uh, to keep our project, you can simply
say, uh, clean.
So I hope you get the idea that how you can do it and make sure whatever changes you made in your unity
project, uh, in unity editor, make sure you just simply press down Ctrl s on your keyboard in order
to save that.
Or you can simply move over to top left file and then click on this save button in order to save your
project.
So I hope you get the idea that how you can do this.