WEBVTT

00:00.040 --> 00:01.720
Let's create the floating text.

00:01.760 --> 00:03.840
It's going to pop up from this anime.

00:04.080 --> 00:04.440
Anime.

00:04.480 --> 00:05.000
One game.

00:05.040 --> 00:06.400
Object or anime.

00:06.760 --> 00:07.800
Once this anime.

00:07.800 --> 00:08.760
One game object.

00:08.800 --> 00:09.960
Takes damage.

00:09.960 --> 00:11.480
So we need to create that.

00:11.480 --> 00:13.320
To create that, we're going to move over to.

00:13.360 --> 00:14.040
Hierarchy.

00:14.240 --> 00:17.280
Let's right click, then create an empty game object.

00:17.280 --> 00:21.640
And we can call this game object to something like a floating text.

00:21.960 --> 00:24.240
Uh, let's call it text instead.

00:24.440 --> 00:25.320
Uh text.

00:25.320 --> 00:30.080
And then what we're going to do, we're going to move over to Inspector, then transform, right click

00:30.080 --> 00:31.480
on it and then reset.

00:31.640 --> 00:34.680
And we're going to press down F in order to focus on it.

00:35.040 --> 00:36.520
And what we're going to do.

00:36.560 --> 00:38.720
We're going to add the text right over here.

00:38.720 --> 00:41.480
To do that select your text in the hierarchy.

00:41.520 --> 00:43.000
Then go over to Inspector.

00:43.040 --> 00:48.600
Then click on this add component and find over here by typing Text Mesh.

00:48.600 --> 00:51.040
So I'm going to type text mesh.

00:51.040 --> 00:53.640
We need to type text mesh and it's going to pop up.

00:54.160 --> 00:56.000
Select this one text mesh.

00:56.000 --> 00:58.640
So just click on it in order to select it.

00:58.840 --> 01:03.440
And what we're gonna do, we're gonna move over to this text field and text.

01:03.440 --> 01:05.960
As you can see, it's totally blank.

01:06.080 --> 01:08.200
So we're going to put 100 something like that.

01:08.200 --> 01:15.560
And now we are not able to notice our text in in the scene view as well as in the game view.

01:15.560 --> 01:17.320
But it kind of seems blurry.

01:17.320 --> 01:24.400
So what we basically have to do, we need to make the this character size to something around 0.1.

01:24.400 --> 01:29.440
And after doing that, make sure you go over to font size and just increase that.

01:29.440 --> 01:32.320
So I'm going to increase with something like 100.

01:32.360 --> 01:36.280
Or by now we can able to see the blurry is gone.

01:36.280 --> 01:40.080
And and basically the weird thing is gone by now.

01:40.400 --> 01:47.880
And instead of making font size little bit bigger, I'm going to make it something around 6060 I guess.

01:47.920 --> 01:50.240
Pretty much cool number as you can see.

01:50.520 --> 01:54.520
And we want to choose this text should be middle in the middle.

01:54.520 --> 01:57.240
So that's why we're going to move over to alignment.

01:57.280 --> 02:00.990
We're gonna select center and a font style.

02:00.990 --> 02:05.590
We're gonna choose bold and we need to put it a put it in the center.

02:05.590 --> 02:08.950
So let's click on this anchor and it says upper left.

02:08.950 --> 02:12.230
So just click there and then choose this middle center.

02:12.230 --> 02:16.870
And as soon as we have chosen we can see by now the text is center.

02:17.150 --> 02:23.110
So we will have the animation something like this text firstly will go up and over time it's gonna fade

02:23.150 --> 02:23.670
out.

02:23.990 --> 02:26.430
So we can simply create the animation.

02:26.430 --> 02:31.030
But it's gonna give us weird movement or weird animation.

02:31.030 --> 02:34.150
It's not gonna be fine at all.

02:34.150 --> 02:39.870
So that's why we need to create an empty parent game object first, and then we need to make this text

02:39.870 --> 02:42.310
game object child of that game object.

02:42.350 --> 02:45.790
Basically, we need to create an empty parent game object.

02:45.990 --> 02:47.990
To do so make sure you go to hierarchy.

02:47.990 --> 02:49.990
Right click or hit this plus icon.

02:50.310 --> 02:51.590
So let's right click.

02:51.590 --> 02:54.070
And we're going to create an empty game object.

02:54.070 --> 02:57.910
And we will call this game object to something like floating text.

02:57.910 --> 02:59.670
So let's call it floating text.

03:00.430 --> 03:00.990
Sorry.

03:01.030 --> 03:02.470
Floating text.

03:02.630 --> 03:06.350
Or we can simply call floating text as well.

03:06.590 --> 03:08.710
I'm going to call this floating text.

03:08.750 --> 03:10.950
And let's go over to Inspector Transform.

03:10.950 --> 03:12.910
Let's right click on it reset.

03:13.150 --> 03:15.390
And I'm going to choose N gizmos for it.

03:15.390 --> 03:16.430
Something like this.

03:16.630 --> 03:18.030
And now what we're going to do.

03:18.070 --> 03:20.070
Or we can remove these gizmos.

03:20.070 --> 03:23.550
So I'm going to select click on this none in the top right.

03:23.750 --> 03:27.470
And now I'm going to select my text game object that we created.

03:27.470 --> 03:31.070
And we're going to drag it on top of this floating text game object.

03:31.070 --> 03:37.550
And now if we select our floating text game object and then select this move tool and then move around

03:37.550 --> 03:41.590
in the scene view, we can see the text game object also going with it.

03:41.630 --> 03:42.110
Why?

03:42.270 --> 03:48.230
Because the text we just made it a child of this floating text game object, as you can see.

03:48.510 --> 03:51.070
And make sure you select your text game object.

03:51.110 --> 03:53.350
Then go over to Inspector, then transform.

03:53.350 --> 03:54.950
Right click and then reset.

03:54.950 --> 03:59.390
So it's going to reset the position as the position of our floating tails.

03:59.430 --> 04:05.830
And now we can create the animation inside this text game object instead of doing inside this floating

04:05.870 --> 04:06.430
text.

04:06.430 --> 04:07.750
So we can do that.

04:08.390 --> 04:11.230
So I hope you get the idea that how you can do it.

04:11.390 --> 04:14.630
And now what we're gonna do, we're gonna create an animation.

04:14.630 --> 04:17.830
So we're gonna have the animation really apologize.

04:17.830 --> 04:19.070
Just wait a moment.

04:23.030 --> 04:24.590
So just wait a moment.

04:24.630 --> 04:25.910
Now it's fine.

04:26.070 --> 04:28.990
So what we will do, we're going to create the animation.

04:28.990 --> 04:32.070
We're not going to do it into this game object.

04:32.070 --> 04:34.470
We're going to do it inside this text game object.

04:34.470 --> 04:38.630
So that's why we just created an empty parent game object first.

04:38.630 --> 04:41.990
And then we just made this text game object child of it.

04:42.110 --> 04:44.070
So we're gonna create inside this text.

04:44.070 --> 04:47.310
But before I do I want to change the font.

04:47.350 --> 04:53.670
So to change in order to change the font we're going to select our text game object underneath our floating

04:53.710 --> 04:55.030
text in the hierarchy.

04:55.260 --> 05:00.020
Then go over to Inspector, then, uh, then make a text mesh component.

05:00.260 --> 05:02.380
And we will move over to font size.

05:02.380 --> 05:04.420
And we're going to make it a little bit small.

05:04.420 --> 05:07.020
But before we do let's change the font.

05:07.220 --> 05:09.500
And we can see in the bottom says font.

05:09.500 --> 05:11.220
And it says none font.

05:11.220 --> 05:13.900
So we can drag any font if we have it.

05:13.900 --> 05:18.500
Or we can simply click in the right section and we can choose the font.

05:18.700 --> 05:25.220
And if you have your font in your project, then you can just head over to your project tab, then assets,

05:25.220 --> 05:28.500
and then uh, I have it inside this fonts folder.

05:28.500 --> 05:32.620
So I'm going to select that and let's select the first font or any of them.

05:32.620 --> 05:35.300
Then drag it over to this font slot.

05:35.460 --> 05:42.820
And as soon as we drag it by now we can see this, uh, this just change immediately the font.

05:43.020 --> 05:46.620
And now by now, we can, uh, create the animation.

05:46.620 --> 05:49.060
So I'm going to leave the font size with 60.

05:49.100 --> 05:50.300
Let's leave that.

05:50.300 --> 05:56.340
But once we're going to make the animation we just want to firstly we will move it up direction in the

05:56.340 --> 06:03.140
Y, in the up direction a little bit and over time we are just gonna make this fade out.

06:03.180 --> 06:08.660
To do so, we're going to select our text game object underneath our floating text in the hierarchy.

06:08.820 --> 06:12.380
Then go over to the animation tab and animation tab.

06:12.380 --> 06:16.500
And let's click on this create button in order to create the animation.

06:16.780 --> 06:18.900
So we will go to assets first.

06:18.900 --> 06:22.100
In the top we can see assets and in assets.

06:22.100 --> 06:26.300
As you can see we already created a folder called animation.

06:26.300 --> 06:29.420
So we're going to open that up by double clicking on it.

06:29.420 --> 06:33.660
And let's create a sub folder for our floating text.

06:33.820 --> 06:37.420
So let's right click and then new folder.

06:37.420 --> 06:43.020
And we can name this folder to something like other animation or animation.

06:43.020 --> 06:48.380
Something like that I'm going to call other underscore animations.

06:48.940 --> 06:50.780
Let's call it something like that.

06:50.780 --> 07:00.660
Any animation let's call it animations, and let's open up this folder by double clicking on it, and

07:00.660 --> 07:02.340
we have to name the animation.

07:02.340 --> 07:10.980
So I'm going to call it something like floating uh, floating uh text animation underscore animation

07:11.900 --> 07:13.740
animation something like that.

07:13.740 --> 07:18.140
And now click on that save button in order to create the animation.

07:18.140 --> 07:23.860
So now what we're gonna do, uh, we will move over to our animation tab and make sure you select your

07:23.860 --> 07:28.300
text GameObject in the hierarchy, not the parent one which is floating text.

07:28.380 --> 07:30.380
So we need to select the child one.

07:30.380 --> 07:36.220
Then go over to animation tab and then click on this red button in order to record your animation in

07:36.220 --> 07:37.860
your animation tab.

07:37.860 --> 07:43.460
So we will move over to something like 160 frame, like something like one second.

07:43.500 --> 07:45.580
As you can see right over here.

07:45.780 --> 07:51.980
And what we're gonna do now, we're gonna select our text and we will move it up a little bit, something

07:52.090 --> 07:53.050
like this much.

07:53.410 --> 07:55.850
Uh, and this much seems pretty much cool.

07:55.850 --> 07:58.290
Let's move it up a little bit more.

07:58.690 --> 08:04.770
And if we just go ahead in animation tab and then click on this play button, we can see the animation.

08:04.770 --> 08:08.330
And over time I also want to increase the font size.

08:08.330 --> 08:12.210
So that's why I'm gonna move over to one second or 60 frame.

08:12.410 --> 08:16.570
Then I'm then I will select my text game object underneath floating text.

08:16.610 --> 08:20.210
Let's go over to Inspector then text mesh component.

08:20.210 --> 08:23.410
And I'm gonna make the font size something like 100.

08:23.650 --> 08:28.450
And over time I want to basically I want to fade out.

08:28.450 --> 08:33.010
So what we will do, we will go over to color in this text based component in the bottom.

08:33.010 --> 08:34.410
Then click there.

08:34.570 --> 08:38.570
And in the bottom you can see a which is set to 255.

08:38.570 --> 08:40.090
So we're gonna make it zero.

08:40.130 --> 08:42.410
Or we can simply drag it like this.

08:42.570 --> 08:45.490
Uh, so it's automatically just gonna fade out.

08:45.490 --> 08:51.090
So if we make it zero and now if we go ahead and then click on this play button in.

08:51.090 --> 08:51.490
Sorry.

08:52.330 --> 08:54.770
We just we have done some mistake.

08:55.250 --> 08:58.810
Um, I guess instead of fading out.

08:58.810 --> 09:02.890
So let's set back to, uh, to five five instead of doing that.

09:02.890 --> 09:06.850
So we're going to set back to two, uh, five five, something like that.

09:07.090 --> 09:08.890
And this seems pretty much cool.

09:08.890 --> 09:10.650
So we can just live with that.

09:10.890 --> 09:13.410
And now it seems pretty much fine.

09:13.410 --> 09:19.890
So if I just go ahead and then click on this play button, we can see that animation is just playing

09:19.890 --> 09:21.490
over again and again.

09:22.010 --> 09:24.330
And we can notice that.

09:24.330 --> 09:27.530
And I want any y a little bit up more.

09:27.810 --> 09:31.370
So in the y I'm going to drag it something like this much.

09:31.610 --> 09:35.530
And if we click on this play button so it seems pretty much fine.

09:35.690 --> 09:41.450
And once you are satisfied then you can just click on this red button to capture your animation.

09:41.810 --> 09:45.730
Uh, to capture your animation once you are satisfied.

09:45.970 --> 09:52.610
And if you don't click on this red button, then it's automatically gonna capture the animation, so

09:52.610 --> 09:55.370
you don't need to worry about anything like that.

09:55.570 --> 10:00.090
And now what we will do, we will make this floating text game object a prefab.

10:00.290 --> 10:03.370
Make sure you basically don't select the child one.

10:03.370 --> 10:07.410
Basically select the parent one and then make that one a prefab.

10:07.530 --> 10:11.810
So we will have the copy and we can spawn wherever we need.

10:11.810 --> 10:14.610
So we're gonna spawn it from this anime game object.

10:14.610 --> 10:19.410
Once it starts taking damage then we're gonna spawn it.

10:19.410 --> 10:22.570
So that's why we're gonna make this floating text a prefab.

10:22.610 --> 10:28.850
To do so, we will head over to our project tab, then assets folder, and then prefabs folder, and

10:28.850 --> 10:31.570
we will select our floating text in the hierarchy.

10:31.730 --> 10:37.570
And let's drag it over to that Flow Prefabs folder in order to turn it into prefab.

10:37.610 --> 10:39.530
Now we turn it into a prefab.

10:39.730 --> 10:45.930
And if we just go ahead and then click on this play button in the top, you will see this floating text.

10:45.970 --> 10:53.040
Just gonna, just gonna play that animation clip, which is which we created earlier inside that text

10:53.040 --> 10:54.680
game object as using.

10:54.920 --> 10:58.760
So that animation just gonna play over again and again.

10:58.760 --> 11:00.360
So we need to stop doing that.

11:00.360 --> 11:06.880
Basically we need to uncheck the loop time of that animation clip inside our floating text underscore

11:06.880 --> 11:09.680
animation that we created recently.

11:10.000 --> 11:12.200
So before we do it let me show you.

11:12.560 --> 11:20.200
So if we start our game we can see this animation is playing over again and again.

11:20.200 --> 11:22.440
And we need to stop doing this.

11:22.440 --> 11:28.600
So that's why we're gonna get out of play mode and we will move over to our project tab then assets.

11:28.800 --> 11:29.280
Sorry.

11:29.640 --> 11:34.920
We will move over to our assets folder, then animation folder in animation folder.

11:34.920 --> 11:40.240
As you can notice we created this other underscore animation folder recently.

11:40.240 --> 11:43.800
So we're gonna open that sub folder by double clicking on it.

11:43.800 --> 11:50.400
And we can notice our floating text floating text underscore animation clip.

11:50.600 --> 11:51.960
And we're going to select that.

11:51.960 --> 11:53.400
Then go over to Inspector.

11:53.400 --> 11:56.200
And we're going to uncheck the loop time so that now.

11:56.240 --> 12:04.040
So by now the floating text basically that animation clip not gonna play over again and again.

12:04.040 --> 12:08.040
So let's click on this play button in the top in order to play our game.

12:08.200 --> 12:10.240
And let's take a look on this.

12:10.240 --> 12:15.680
So the animation will be fine by now it's not gonna play over again and again.

12:15.800 --> 12:18.480
It's gonna play one time and that's all.

12:19.680 --> 12:24.960
And we also need to delete this floating text in the hierarchy for now.

12:25.120 --> 12:27.440
We need to spawn it when we need it.

12:27.440 --> 12:36.200
So before we do it, let's have a look so we can see that the animation is not looping at all.

12:36.440 --> 12:40.400
So the animation not looping not looping.

12:40.400 --> 12:41.600
And that's fine.

12:41.600 --> 12:46.360
So we will get out of play mode and we will select our floating text in the hierarchy.

12:46.640 --> 12:50.840
and we're gonna delete it because we don't need it, but when we need it.

12:51.000 --> 12:56.520
Once this anime one start taking damage, then we're gonna spawn this floating text for.

12:56.560 --> 12:58.520
So for now, we're gonna destroy that.

12:58.520 --> 13:01.120
Basically, we're gonna delete it from the hierarchy.

13:01.160 --> 13:03.120
As well as in the scene view.

13:03.120 --> 13:05.800
So we're going to select our floating text in hierarchy.

13:06.000 --> 13:08.920
And let's press down delete in order to delete that.

13:08.920 --> 13:11.000
And now we're gonna spawn it when.

13:11.200 --> 13:15.240
Our enemy one GameObject start taking damage.

13:15.240 --> 13:16.800
So we're gonna do that.

13:17.520 --> 13:19.680
So let's do it over here.

13:19.760 --> 13:23.360
So firstly I'm going to select my enemy one game object in the hierarchy.

13:23.560 --> 13:24.960
And let's open up the enemy.

13:25.000 --> 13:27.680
One script by double clicking on on it.

13:27.800 --> 13:31.440
And what we will do we're gonna spawn it to spawn it.

13:31.480 --> 13:35.440
We need a reference of that floating text prefab that we created.

13:35.480 --> 13:37.120
Basically, if we move over to.

13:37.160 --> 13:44.400
Unity editor, then move over to this project tab and then assets and then prefabs folder, we can see.

13:44.440 --> 13:50.910
Our floating text game object is over here, so we need a reference of this floating text game object.

13:50.910 --> 13:52.230
Then we can spawn it.

13:52.230 --> 13:53.950
So let's grab the reference first.

13:53.950 --> 13:55.710
So we will move over to script.

13:55.710 --> 14:00.190
Let's go to the top of our class and let's make it over here.

14:00.190 --> 14:02.510
So let's make a serialized field.

14:02.990 --> 14:06.310
Serialized field private uh private.

14:06.310 --> 14:12.190
And the game object we are looking for is a floating text prefab or that floating text game object.

14:12.190 --> 14:15.430
So that floating text itself, a whole game object.

14:15.430 --> 14:18.790
So that's why we need to type this game object type variable.

14:18.790 --> 14:24.390
And we can call this one to something like floating floating text prefab.

14:24.390 --> 14:27.510
So let's call it floating text prefab.

14:27.750 --> 14:30.110
And then close that up with semicolon.

14:30.110 --> 14:33.150
And we're going to press Ctrl S to save our script.

14:33.150 --> 14:35.110
And now let's move over to unity.

14:35.430 --> 14:41.990
So as soon as our script just gonna compile underneath our enemy one script, we will be able to notice

14:42.030 --> 14:47.590
a, uh, you can simply say, uh, a message.

14:47.590 --> 14:49.430
Just gonna, uh, sorry.

14:49.470 --> 14:51.910
Underneath our enemy won't skip a file.

14:51.910 --> 14:55.630
Just gonna appear and it will say floating text prefab.

14:55.630 --> 15:01.230
So what we need to do there, we basically need to select this floating text prefab game object.

15:01.230 --> 15:03.510
And we need to drag it in that slot.

15:03.510 --> 15:04.910
So we will have the reference.

15:04.910 --> 15:08.030
And after that we can spawn it when we need that.

15:08.030 --> 15:10.350
So just wait a moment and you will see.

15:20.350 --> 15:22.430
So just wait a moment.

15:23.550 --> 15:29.310
So now if I select my enemy one GameObject in the hierarchy and then go over to Inspector.

15:29.310 --> 15:30.430
So just wait.

15:30.470 --> 15:33.150
We can see underneath our enemy one script.

15:33.150 --> 15:39.550
In this health title, we can see that we have floating text prefab and it says non game object.

15:39.550 --> 15:44.990
So we will simply select that floating text prefab game object from our prefabs folder.

15:45.030 --> 15:46.870
Then drag it over to this slot.

15:46.910 --> 15:53.430
Now we can see that we have the floating text game object, and we are ready to spawn it to spawn it.

15:53.470 --> 15:59.070
Let's open up our anime one script and we're gonna spawn it when we take damage.

15:59.070 --> 16:03.270
So basically we will move over to our Takedamage function over here.

16:03.270 --> 16:05.550
As you can notice, we taking damage.

16:05.590 --> 16:07.630
We playing the heart animation clip.

16:07.630 --> 16:09.910
So in that moment we need to spawn it.

16:09.910 --> 16:17.190
And we do know that in order to spawn it we need to use this instantiate function and this instance

16:17.910 --> 16:19.510
function as a first argument.

16:19.510 --> 16:22.510
It's going to take the game object that we want to spawn.

16:22.510 --> 16:25.910
So in our case it will be floating text prefab.

16:25.910 --> 16:32.310
And we do know that in floating text prefab we just drag it that floating text as you seen in Inspector

16:32.430 --> 16:32.830
Comma.

16:32.870 --> 16:35.030
Second thing, it's going to take the position.

16:35.030 --> 16:42.830
So we're gonna spawn it from our center position of anime one game object so we can simply pass transform.position

16:42.830 --> 16:50.670
means that enemy position, enemy position, or current current position of that enemy one game object

16:50.670 --> 16:53.190
and the third argument is going to take the rotation.

16:53.190 --> 16:56.110
So we're going to pass our quaternion dot identity.

16:56.350 --> 16:58.350
It's basically means no rotation.

16:58.350 --> 17:02.070
So let's pass quaternion dot identity.

17:02.230 --> 17:04.390
And let's close that off with semicolon.

17:04.750 --> 17:11.150
So now we spawning this floating text prefab at this position with no rotation.

17:11.150 --> 17:13.310
As you can notice right over here.

17:13.430 --> 17:17.310
And now we're going to press down Ctrl S in order to save our script.

17:17.310 --> 17:19.470
And now let's move over to unity.

17:19.470 --> 17:24.830
So as soon as our ship just gonna compile underneath our enemy one script.

17:25.110 --> 17:28.350
Sorry, not underneath our enemy one script.

17:28.390 --> 17:34.310
Basically, as soon as we're gonna damage our enemy, one game object, you will see that floating text

17:34.310 --> 17:42.140
prefab just gonna spawn from the from that, uh, basically from this anime one game object.

17:42.900 --> 17:46.340
Uh, so just wait a moment and you will see that.

17:48.260 --> 17:50.100
So now it's, uh, fine.

17:51.060 --> 17:52.580
So let's have a look.

17:52.580 --> 17:56.580
So I'm going to click on this play button in the top in order to play my game.

17:56.580 --> 17:58.700
And let's take a look on this.

18:05.380 --> 18:07.220
So just wait a moment.

18:08.540 --> 18:14.180
And now if we just get closer to this anime one game object and damage it.

18:14.580 --> 18:15.980
So we can see by now.

18:15.980 --> 18:21.660
As you can notice, the floating text prefab just getting spawned from this anime game object center

18:21.660 --> 18:22.340
position.

18:22.580 --> 18:28.660
Instead of spawning that over here center position, we're gonna spawn it something like top of this

18:28.700 --> 18:34.260
anime, one game object hat or something like from chest so we can spawn it.

18:34.260 --> 18:41.980
So let's create a point in order to spawn spawn that basically this floating text prefab from that position.

18:41.980 --> 18:43.580
So let's get out of play mode.

18:43.580 --> 18:46.380
So let's create a point somewhere over here.

18:46.380 --> 18:49.820
So we will select our enemy one GameObject in the hierarchy.

18:49.820 --> 18:54.460
And let's create an empty game object inside this enemy point game object.

18:54.460 --> 18:56.060
So let's right click on it.

18:56.100 --> 18:58.420
Let's create an empty game object.

18:58.420 --> 19:02.100
And we can call this GameObject to something like Spawn Point.

19:02.260 --> 19:04.900
So let's call it Spawn Point.

19:05.100 --> 19:11.060
And let's select this spawn point underneath our enemy one GameObject in the hierarchy.

19:11.260 --> 19:14.180
And let's move it somewhere around here.

19:14.420 --> 19:18.180
And if you want to choose an gizmos then go over to Inspector.

19:18.180 --> 19:23.340
Click here and we're going to choose this, uh, this green one, something like that.

19:23.340 --> 19:26.060
So from this position we want to spawn it.

19:26.060 --> 19:28.780
So we need a reference of this spawn point.

19:28.780 --> 19:31.820
Then we can just spawn from this position.

19:31.820 --> 19:35.380
So let's grab the reference first basically this position.

19:35.700 --> 19:39.580
So let's open up our enemy one script by double clicking on it.

19:39.620 --> 19:44.100
Let's go to the top of our class and let's grab the reference of that position.

19:44.220 --> 19:46.340
So let's make a serialized field.

19:46.700 --> 19:50.260
So let's make a serialized field a private.

19:50.540 --> 19:52.340
And we're looking for position.

19:52.700 --> 19:58.380
So we need to type this transform which is responsible for position rotation and scale.

19:58.540 --> 20:01.660
And we can call this one to something like spawn point.

20:01.940 --> 20:03.660
Let's call it spawn point.

20:03.660 --> 20:05.700
And let's close that up with semicolon.

20:05.700 --> 20:08.820
And we're going to press down Ctrl S to save our script.

20:08.820 --> 20:10.820
And now let's move over to unity.

20:10.980 --> 20:16.700
So underneath our enemy one script and another filter's gonna pop up says Spawn Point.

20:16.780 --> 20:22.660
So what we need to do there, we basically need to select this spawn point underneath our enemy one

20:22.660 --> 20:24.220
GameObject in the hierarchy.

20:24.380 --> 20:26.900
And we need to drag it over to that slot.

20:26.900 --> 20:28.300
So we will have the point.

20:28.300 --> 20:31.940
And after that we can just spawn it from that position.

20:31.940 --> 20:33.340
So just wait a moment.

20:33.780 --> 20:37.810
And now as soon as our enemy one square enemy.

20:37.810 --> 20:39.610
One script just gets compiled.

20:39.650 --> 20:42.930
We can see spawn point and it says None Transform.

20:42.930 --> 20:46.730
So we will select our spawn point and drag it over to that field.

20:46.770 --> 20:52.290
Now we can see we have the spawn point and we are ready to spawn it from this position.

20:52.290 --> 20:58.610
So let's move over to our enemy one script and let's move over to our function, in which function we

20:58.610 --> 21:00.730
spawning basically over here.

21:00.730 --> 21:05.810
As you can notice, we spawning this floating text prefab at this position.

21:05.810 --> 21:13.650
So instead of spawning from that transform.position basically means current position of that enemy one

21:13.650 --> 21:14.250
game object.

21:14.250 --> 21:21.570
Instead of spawning from that, we're going to pass our spawn point spawn point dot position as we created.

21:21.610 --> 21:27.650
Now this floating text prefab right over here, it's gonna spawn from this position which spawn point

21:27.690 --> 21:28.570
dot position.

21:29.170 --> 21:36.850
So and we do know that spawn point in, we just drag it that spawn point into our spawn point fail so

21:36.890 --> 21:42.770
that this floating text prefab just gonna spawn from this position, which is spawn point dot position

21:42.770 --> 21:45.130
with no rotation, as you can notice.

21:45.330 --> 21:49.090
And now we're gonna press down Ctrl S in order to save our scape.

21:49.130 --> 21:50.810
Let's move over to unity.

21:51.290 --> 21:58.250
So we will see by now that a floating text prefab game object or that floating text game object just

21:58.250 --> 22:04.490
gonna spawn from this spawn point that we created and make sure you drag it your spawn point to spawn

22:04.490 --> 22:10.490
point fill, so you will have the reference of the position, and after that you can able to spawn it

22:10.490 --> 22:11.970
from that position.

22:11.970 --> 22:15.930
So now script is a script, compilation is done.

22:16.250 --> 22:22.930
And if we just go ahead and then click on this play button in the top in order to play our game and

22:22.930 --> 22:31.810
start damaging our enemy one game object, you will notice that a floating text prefab just just gonna

22:31.810 --> 22:33.930
spawn from this spawn point.

22:33.930 --> 22:35.970
So let's get closer to this anime.

22:36.010 --> 22:44.170
One game object and if I damage it, we can see by now that is spawning from over here from this spawn

22:44.170 --> 22:44.650
point.

22:44.690 --> 22:45.730
As soon as.

22:45.770 --> 22:46.290
Sorry.

22:46.650 --> 22:51.450
As soon as we just damaging our enemy one game object as you can notice.

22:51.450 --> 22:54.850
So we can drag our this position a little bit up.

22:54.850 --> 22:57.490
So what we can do, we can get out of play mode.

22:57.490 --> 23:01.130
And let's select this spawn point and let's drag it a little bit up.

23:01.130 --> 23:07.170
Something over here or top of this anime -- game object head head position.

23:07.450 --> 23:08.490
So now that's fine.

23:08.490 --> 23:11.330
And make sure you select your anime one game object.

23:11.330 --> 23:14.930
Then go over to Inspector Overrides and then apply all.

23:15.210 --> 23:20.930
If you turn it your anime one into a prefab, then you can do that or else you need to.

23:21.130 --> 23:22.130
You don't need to do.

23:22.130 --> 23:27.770
But the problem is that if we go ahead and then click on this play button, you will see that, uh,

23:27.770 --> 23:34.480
those, uh, floating takes a game object is spawning, but it's not getting destroyed it after some

23:34.480 --> 23:35.480
period of time.

23:35.480 --> 23:38.240
So we need we also need to destroy it.

23:38.240 --> 23:41.080
So to make our game a game clean.

23:41.360 --> 23:45.320
Clean or over time our frame rate just gonna shrink down.

23:45.320 --> 23:48.760
Or simply you can say the game will be laggy.

23:48.760 --> 23:53.320
So that's why game will be laggy because it's gonna hold to many game objects.

23:53.320 --> 23:58.360
So that's why the frame rate is just gonna be less so over time.

23:58.360 --> 23:59.680
So that is the reason.

23:59.680 --> 24:07.400
So if I damage my enemy one game object, we can see, uh, this 100 just pop up basically that, uh,

24:08.440 --> 24:10.000
uh, that floating takes prefab.

24:10.000 --> 24:15.600
But the problem is that we still able to notice our floating text in the scene view.

24:15.600 --> 24:21.040
And if we move over to hierarchy, we can see we have the floating text clone game object.

24:21.040 --> 24:26.440
So we also need to destroy this floating text after some period of time.

24:26.440 --> 24:28.960
So what we will do, we will get out of play mode.

24:29.080 --> 24:35.440
Uh, so to destroy after some period of time, we need to check after how much time we just completing

24:35.440 --> 24:37.440
the animation clip, so we will.

24:37.480 --> 24:40.600
For that we will head over to our project tab.

24:40.880 --> 24:46.800
Then we will move over to assets folder, then prefabs folder and we will open up the floating text

24:46.920 --> 24:49.080
prefab by double clicking on it.

24:49.080 --> 24:55.680
And if we select our text underneath our floating text GameObject in the hierarchy, then go over to

24:55.720 --> 24:56.760
animation tab.

24:56.800 --> 25:05.080
We can see after one second or 60 frame we just completing the whole animation clip as you can notice.

25:05.080 --> 25:11.480
So after this amount of time, basically after one second we need to destroy this floating text game

25:11.520 --> 25:16.520
object right away after after playing the animation clip completely.

25:16.520 --> 25:19.560
So after this much of time, we need to destroy that.

25:19.560 --> 25:22.600
So to go back in hierarchy we can see back arrow.

25:22.600 --> 25:26.200
So let's click there in order to go back into this in view.

25:26.200 --> 25:31.040
So after one second we need to destroy that floating text prefab game object.

25:31.040 --> 25:33.680
So we will open up our anime one script.

25:33.680 --> 25:36.400
So we is spawning this floating text prefab.

25:36.440 --> 25:40.920
As you can notice right over here at this position with no rotation.

25:40.920 --> 25:45.000
So after spawning that we're going to store it into another game object.

25:45.400 --> 25:47.960
That floating text prefab that we spawn it.

25:48.000 --> 25:50.640
We're going to store it into another container.

25:50.640 --> 25:54.120
And the container is just going to be a game object type container.

25:54.160 --> 25:54.600
Why?

25:54.720 --> 25:58.320
Because this floating takes prefab itself a whole game object.

25:58.320 --> 26:03.640
So that's why we need to put it a container or a variable, which should be a game object type.

26:03.800 --> 26:05.960
So we need to type this game object.

26:05.960 --> 26:10.560
And then we have to name the container or the variable where we want to store it.

26:10.560 --> 26:18.600
So we're going to call it something like tame floating text prefab floating text prefab like that.

26:18.600 --> 26:19.760
We're going to call it.

26:19.760 --> 26:21.920
And then let's set equal to this.

26:21.920 --> 26:27.440
So firstly what we're doing we just spawning this floating text prefab at this position which is spawn

26:27.440 --> 26:30.240
point dot position with no rotation.

26:30.240 --> 26:33.030
And after that we're just taking that what we spawned.

26:33.030 --> 26:35.350
So we spawned this floating text prefab.

26:35.630 --> 26:40.390
And then we're storing into this float atom floating text prefab GameObject.

26:40.430 --> 26:47.070
Basically we are taking this floating text prefab, what we spawn it and we're storing into this temp

26:47.190 --> 26:49.510
floating text prefab GameObject.

26:49.510 --> 26:56.230
So what we need to do now we need to destroy this temp floating text prefab GameObject after one second.

26:56.270 --> 26:59.590
Basically where we store it our floating text prefab.

26:59.590 --> 27:01.550
So we also need to destroy it.

27:01.550 --> 27:07.830
So that's why after spawning, we're going to use this destroy function in order to destroy as a first

27:07.830 --> 27:11.350
argument, it's going to take the game object that we want to destroy.

27:11.350 --> 27:17.350
So we're going to pass this temp floating text prefab basically where we store it our other floating

27:17.390 --> 27:18.430
text game object.

27:18.430 --> 27:23.990
And the second thing we can specify the time after how much time we want to destroy it.

27:24.030 --> 27:31.190
So as you've seen that after one second it's completely it's just completing the whole animation clip.

27:31.190 --> 27:38.350
So that's why after one second we want to destroy this team floating text prefab or where we store that

27:38.550 --> 27:40.950
floating text prefab game object.

27:40.950 --> 27:41.990
So we're going to destroy.

27:41.990 --> 27:48.390
So we simply destroying the container where we storing or we in which variable we storing.

27:48.430 --> 27:50.870
We just destroying that as well.

27:50.870 --> 27:53.110
So after one second we want to do so.

27:53.110 --> 27:54.910
That's why we're going to put one f.

27:54.910 --> 27:57.790
Or you can simply say after one second.

27:58.110 --> 27:59.150
So just wait.

27:59.190 --> 28:00.550
It's a little bit lagging.

28:00.830 --> 28:03.350
So we're going to put one F and then sorry.

28:04.910 --> 28:06.470
So this will be one f.

28:06.510 --> 28:08.510
And let's close that up with semicolon.

28:08.510 --> 28:12.270
And we're going to press down Ctrl s in order to save our script.

28:12.270 --> 28:14.190
And now let's move over to unity.

28:14.350 --> 28:21.110
So you will see as soon as those floating takes prefab just gonna spawn from this enemy one GameObject

28:21.150 --> 28:22.110
spawn point.

28:22.150 --> 28:29.230
After one second you will see those will be destroyed because firstly we spawning it and after recording

28:29.230 --> 28:36.830
it, we just storing that into a floating text prefab container as you've seen inside our script.

28:36.950 --> 28:41.270
So after one second we also destroying the container where we're storing that.

28:41.270 --> 28:43.830
So we are destroying as well.

28:44.110 --> 28:50.190
Uh, or you can simply say we destroying the floating text prefab that we spawned after one second.

28:50.390 --> 28:52.310
So just wait a little moment.

28:52.350 --> 28:59.230
Once our script compilation is done, we can just check that out by clicking on this play button in

28:59.230 --> 29:03.110
the top in order to start our game in order to check it.

29:03.230 --> 29:07.630
So just wait a little moment, uh, for my slow system.

29:07.630 --> 29:10.910
So that's why it's taking a little bit longer time.

29:11.350 --> 29:17.710
And now if we go ahead and then click on this play button and then damage this enemy one game object,

29:17.710 --> 29:18.510
you will see.

29:18.990 --> 29:25.350
So as soon as we're gonna start a start damaging this enemy one, it's gonna spawn that floating text

29:25.350 --> 29:32.180
prefab and that floating text takes prefab game object just gonna destroy itself after one second.

29:32.220 --> 29:33.660
So let's take a look on this.

29:33.660 --> 29:37.340
So firstly we're gonna get closer to this anime one game object.

29:37.340 --> 29:42.660
And if we start damaging our enemy one, we can see it's spawning.

29:42.660 --> 29:49.500
And after one second we can notice that that floating takes prefab just destroying itself after spawning.

29:49.860 --> 29:52.900
Basically after completing the whole animation clip.

29:52.900 --> 29:56.260
And we can notice in this in view as well as in the hierarchy.

29:56.380 --> 30:03.500
So if we move over to hierarchy, we cannot see any floating text prefab or floating text clone, as

30:03.500 --> 30:06.820
you can notice in the hierarchy as well as in the scene view.

30:06.820 --> 30:10.220
So after one second it's just getting destroyed itself.

30:10.220 --> 30:16.300
And you can notice in the hierarchy as well as in the scene view as well as in the game view.

30:16.300 --> 30:21.100
So I hope you get the idea that how you can do it and I'm gonna get out of play mode.

30:21.100 --> 30:23.980
So I hope you get the idea that how you can do it.

30:25.340 --> 30:27.100
So that's fine.
