WEBVTT

00:00.040 --> 00:01.560
We will create floating text.

00:01.560 --> 00:07.680
Basically, once this player GameObject attack on this enemy GameObject and this enemy just takes damage,

00:07.680 --> 00:10.080
we want to show up the floating text.

00:10.080 --> 00:11.480
So we're going to create that.

00:11.480 --> 00:15.160
So before we create we're going to create an empty game object.

00:15.160 --> 00:19.760
And we're going to make that text a child because we're going to have the animation.

00:19.760 --> 00:23.520
Firstly the text will go up and over time it's going to fade out.

00:23.520 --> 00:27.400
So that's why firstly we need to create an parent game object.

00:27.400 --> 00:28.600
So let's go to hierarchy.

00:28.600 --> 00:30.640
Right click or hit this plus icon.

00:30.640 --> 00:33.000
And we're going to create an empty game object.

00:33.000 --> 00:41.360
And I'm going to name this game object to something like floating text floating floating text floating

00:41.400 --> 00:42.000
text.

00:42.040 --> 00:46.000
And I'm going to choose an icon for that something this one.

00:46.000 --> 00:47.880
Or we can simply choose any.

00:48.360 --> 00:54.320
And now I'm going to drag it top up in my hierarchy, this game object, so I can see all the time.

00:54.320 --> 00:55.600
And what we're going to do now.

00:55.600 --> 01:00.750
We're going to create an empty game object and into that child game object we're going when I add the

01:00.750 --> 01:06.430
tags, uh, because we're gonna have the animation and we're going to create the animation in the game

01:06.470 --> 01:12.590
object, or it's kind of gonna be weird if you just don't create an parent game object.

01:12.590 --> 01:17.750
So make sure you just do that because we're gonna have the animation in our child game object.

01:17.750 --> 01:22.790
So that is the reason, or else we're gonna get some weird, uh, animations.

01:22.790 --> 01:23.630
So that's why.

01:23.750 --> 01:26.470
So let's select the floating text game object.

01:26.470 --> 01:30.670
Let's right click on it and let's create an empty game object.

01:30.670 --> 01:35.030
And I'm gonna name this game object to something like text uh text.

01:35.190 --> 01:41.110
And what we will do, we're gonna add a text mesh component to this text in order to be able to see

01:41.150 --> 01:42.230
our text.

01:42.230 --> 01:44.710
So select the text game object in the hierarchy.

01:44.750 --> 01:50.030
Go over to Inspector, click on Add Component and we're going to add a text message text mesh.

01:50.070 --> 01:51.190
Don't add this text.

01:51.190 --> 01:53.750
Instead you need to attach this text mesh.

01:54.110 --> 01:56.470
So just click there in order to attach.

01:56.470 --> 02:00.650
And we're not able to see our text because this takes over here.

02:00.690 --> 02:02.090
Field is totally blank.

02:02.090 --> 02:03.930
So we're going to put something like 100.

02:03.970 --> 02:09.250
As soon as we have chosen 100, we can see we are now able to see our text.

02:09.250 --> 02:10.610
But it's kind of bit weird.

02:10.610 --> 02:14.810
So what we need to do, we need to move over to this character size.

02:14.810 --> 02:17.570
And we need to make it as much small we can.

02:17.570 --> 02:19.890
So I'm going to make it something like 0.1.

02:19.890 --> 02:25.050
And after doing that make sure you just go over to this font size and increase the font size.

02:25.050 --> 02:28.090
So I'm going to increase something like 100.

02:28.090 --> 02:32.250
And now we are able to see and font style I'm going to choose bold.

02:32.530 --> 02:33.730
And this is fine.

02:33.730 --> 02:35.090
And we need to center it.

02:35.090 --> 02:38.610
This text uh in this floating text game object.

02:38.610 --> 02:39.650
So what are we going to do now.

02:39.650 --> 02:44.450
We're going to choose alignment to center as well as anchor to upper left.

02:44.450 --> 02:48.450
From this upper left we're going to choose middle center as soon as we done.

02:48.450 --> 02:52.170
Now that text is now centered as you can see.

02:52.330 --> 02:56.650
And if you have any font then you can just drag it over to this font field.

02:56.650 --> 03:00.320
Or you can just click over here in order to choose a font.

03:00.360 --> 03:02.760
So I'm going to drag a font right over here.

03:02.800 --> 03:04.680
A monochrome, uh, font.

03:05.000 --> 03:07.800
Uh, of course I will have a link in the resources.

03:07.800 --> 03:09.880
You can go and check that out.

03:09.920 --> 03:15.800
So I'm going to move over to my project tab assets and then uh fonts folder I have many fonts.

03:15.800 --> 03:20.640
So let's suppose I'm going to select the first one and drag it over to this font filled in Inspector.

03:20.680 --> 03:24.600
As soon as we drag it now we able to see our font.

03:24.640 --> 03:28.920
The text just gets with our, uh, gets changed with our font.

03:29.080 --> 03:32.280
And I'm gonna do with this one as well.

03:32.480 --> 03:36.240
It's basically up to you which font you just want to choose.

03:36.240 --> 03:40.880
And I'm going to make the font size a little bit up, something like one, two, five.

03:41.640 --> 03:43.600
And it's pretty much cool.

03:43.600 --> 03:45.680
So now let's make the animation.

03:45.680 --> 03:49.040
So make sure you select the tile game object, not the parent one.

03:49.040 --> 03:52.400
So that's why we just created a parent game object first.

03:52.400 --> 03:55.080
And then we just created a text game object.

03:55.080 --> 04:00.580
And we just attach the text into this game object because we're going to have the animation in this

04:00.580 --> 04:06.740
text game object, not in this floating text game object, or else the animation just gonna be weird.

04:06.740 --> 04:08.540
So that's why we have to do so.

04:08.540 --> 04:10.500
We're going to make the animation by now.

04:10.500 --> 04:14.820
So let's select the text game object underneath our floating text in the hierarchy.

04:14.820 --> 04:20.780
Let's move over to animation tab and let's click on this create button in order to create the animation.

04:20.780 --> 04:25.460
So I'm going to move over to my assets folder basically where I have the animation folder.

04:25.460 --> 04:26.740
So I'm going to open that up.

04:26.740 --> 04:28.500
So let's double click on it.

04:28.500 --> 04:34.620
And I'm going to move over to this add stop animation stop underscore animation sub folder.

04:34.620 --> 04:37.620
And we have to name the animation what we want to name it.

04:37.620 --> 04:43.540
So I'm going to call it something like floating floating floating text.

04:43.980 --> 04:47.180
Or we can simply call floating underscore text.

04:47.340 --> 04:49.180
And let's click on the save button.

04:49.180 --> 04:51.620
And we are ready to create the animation.

04:51.620 --> 04:57.610
But before you create make sure you just hit this red button in animation tab in order to record your

04:57.650 --> 04:58.410
animation.

04:58.410 --> 05:04.370
And I'm going to move over to something like 160 frames or this, uh, over here in one second.

05:04.490 --> 05:07.330
And I'm gonna move this a little bit up this text.

05:07.330 --> 05:09.570
So select the child one, not the parent one.

05:09.570 --> 05:13.210
Select the child and we're going to move it up something like this much.

05:13.370 --> 05:17.130
And also I just want to make this one transparent.

05:17.130 --> 05:21.130
So it's gonna seems like it's fading out over time.

05:21.130 --> 05:25.450
So let's select the text and let's go to inspector then mesh renderer.

05:26.530 --> 05:29.810
Mesh renderer not sorry not mesh renderer.

05:29.850 --> 05:32.330
Basically we need to go over to this text mesh.

05:32.330 --> 05:34.290
And in the bottom you can see color field.

05:34.290 --> 05:39.850
So just click there and then you can just drag this a in the bottom you can see 255.

05:39.890 --> 05:41.090
So I'm going to make it zero.

05:41.090 --> 05:44.010
Or we can just drag it all the way to the zero.

05:44.210 --> 05:49.410
And now if I just click on this play button in animation tab we can see our animation.

05:49.650 --> 05:52.650
But uh we get some error.

05:53.330 --> 05:55.490
So it's kind of bit weird.

05:55.490 --> 05:56.430
So what we're are we going to do?

05:56.470 --> 05:58.630
We're going to leave that instead.

05:58.630 --> 06:01.310
So I'm going to move over to my color field once again.

06:01.310 --> 06:04.270
And I'm going to move this all the way to 100.

06:04.310 --> 06:05.670
Something like that.

06:05.670 --> 06:08.470
And we can just go over to this materials.

06:08.470 --> 06:09.990
I guess it's fine.

06:10.350 --> 06:15.670
Uh, so we can just ignore this thing as well, but you can just rotate, uh, as well.

06:15.670 --> 06:21.670
So if you just move over to once again, basically 60 frame, and let's suppose you just want to rotate

06:21.670 --> 06:25.150
this text a little bit in any direction.

06:25.150 --> 06:28.030
Then you can just go over to transform rotation.

06:28.030 --> 06:31.310
And you can just play around with z axis as well.

06:31.550 --> 06:37.310
So now if I just click on this play button, as you can see it's going up and it's just rotating a little

06:37.350 --> 06:37.710
bit.

06:37.910 --> 06:41.430
So what I'm going to do now basically I don't want to do this thing.

06:41.430 --> 06:43.870
So I'm going to set back to zero instead.

06:43.870 --> 06:50.310
I just want to uh basically this takes uh to be small, something like that.

06:50.710 --> 06:56.460
So by default we just want this text to be, uh, in size, something like 125.

06:56.460 --> 06:59.860
So let's hit this red button in order to capture the animation.

07:00.060 --> 07:04.660
And by default, what I'm going to do, I'm going to make this font size a little bit small.

07:04.660 --> 07:11.300
And then once this takes pop up, then over time I'm going to just increase the size of this text as

07:11.300 --> 07:11.700
well.

07:11.900 --> 07:14.340
So let's select the text in our hierarchy.

07:14.380 --> 07:17.380
Make sure you just hit this red button.

07:17.380 --> 07:23.260
So make sure you just out of the record of your animation by hitting this red button.

07:23.260 --> 07:24.700
And then you have to do it.

07:24.700 --> 07:28.500
So I'm going to select my text game object underneath my floating text.

07:28.540 --> 07:33.060
And let's make the font size something like, uh, ten I guess.

07:33.180 --> 07:34.900
Or we can simply make 50.

07:35.140 --> 07:41.300
And once we create the animation, basically it's going to go up and over time it's going to increase

07:41.300 --> 07:42.780
the size itself.

07:42.780 --> 07:48.340
So when I hit this record button, red button in order to capture the animation and I'm gonna move uh,

07:48.380 --> 07:50.580
60 frames, something like that.

07:50.580 --> 07:54.340
And now what I'm gonna do, I'm gonna increase the font size.

07:54.400 --> 07:56.680
So we will go to text and the font size.

07:56.680 --> 07:58.840
I'm going to make it something like 125.

07:59.040 --> 08:03.800
And if we just click on this play button by now, we can see it's just going up.

08:03.800 --> 08:07.760
And over time the font just increasing as you can see.

08:07.760 --> 08:09.400
So you can just play around with.

08:09.400 --> 08:15.680
And once you set it satisfied then you can just click on this red button to capture the animation.

08:15.680 --> 08:17.440
Or you can just leave it like that.

08:17.440 --> 08:20.560
It's automatically gonna capture the animation.

08:21.000 --> 08:22.280
So what are we gonna do now?

08:22.280 --> 08:25.320
We're gonna make this floating text game object a prefab.

08:25.320 --> 08:29.280
So we're gonna have the copy and we can spawn it anywhere we want.

08:29.520 --> 08:34.160
Something like, once this enemy game object takes damage, then we're gonna spawn this.

08:34.160 --> 08:36.080
So let's make this one a prefab.

08:36.080 --> 08:37.560
So we're gonna have the copy.

08:37.560 --> 08:40.600
So we're gonna select our floating text game object.

08:40.600 --> 08:46.960
And let's drag it over to this prefabs folder into this project app, firstly project app, then assets.

08:46.960 --> 08:49.680
And you can just drag it over here as well.

08:49.680 --> 08:56.630
But it would be nice if you just create a prefab folder and just drag it there to keep your project

08:56.630 --> 08:57.110
clean.

08:57.270 --> 09:03.390
And what we will do, we're going to create a script because we don't want this number to be 100 always.

09:03.390 --> 09:06.150
We just want to choose a random number.

09:06.350 --> 09:08.510
And then we're going to show that up.

09:08.510 --> 09:12.710
So we're going to create a floating text script in order to do it.

09:12.710 --> 09:17.150
So let's move over to this project tab then assets and then script folder.

09:17.190 --> 09:20.750
Let's right click there create and then Monobehaviour script.

09:20.750 --> 09:23.230
And you can name that script what you like.

09:23.510 --> 09:29.150
I already have created a script for that and I just name it Floating text as you can see.

09:29.150 --> 09:34.310
So now what we're gonna do, we're gonna attach this script to our floating text game object, basically

09:34.310 --> 09:35.670
to the parent one.

09:35.670 --> 09:39.070
So let's select that, drag it over to this Add Component section.

09:39.070 --> 09:42.830
And let's double click this to open it up in Visual Studio.

09:42.830 --> 09:48.070
So what we're going to do we're going to remove this uh update function as well as I'm going to remove

09:48.070 --> 09:50.270
this comment.

09:50.310 --> 09:54.210
We don't need uh instead we need a reference of this text message.

09:54.210 --> 09:57.690
So if I select the text game object and then go over to text Mesh.

09:57.690 --> 09:59.890
So we need a reference of this text mesh.

09:59.890 --> 10:01.850
And we can see over here 100.

10:01.850 --> 10:03.770
So we need a reference of this.

10:03.810 --> 10:08.250
Then we can change this number any number that we would like to go with.

10:08.290 --> 10:10.410
Or we're going to choose a random one.

10:10.410 --> 10:12.650
So firstly we need a reference of this.

10:12.650 --> 10:15.490
So let's go to script and let's grab the reference first.

10:15.490 --> 10:17.210
So I'm going to make a public.

10:17.490 --> 10:20.210
And the component we're looking for is a text mesh.

10:20.210 --> 10:23.330
So we need to type the component which is text mesh.

10:23.370 --> 10:28.850
And we can call this one to something like with non capitalized t letter text mesh.

10:28.850 --> 10:30.610
And let's close that up with semicolon.

10:30.610 --> 10:33.890
And we're going to press down Ctrl S in order to save our script.

10:33.930 --> 10:35.530
And let's move over to unity.

10:35.690 --> 10:41.530
So underneath our floating text script we're going to able to see a text message F is just going to

10:41.530 --> 10:41.970
appear.

10:41.970 --> 10:45.970
So what we need to do there we need to drag this text into that slot.

10:46.010 --> 10:51.650
So we're going to have this text mesh reference R a reference text mesh component reference.

10:51.650 --> 10:57.400
Then we can just change the number with a random number, so just wait for it to compile.

10:57.640 --> 11:03.560
And now if I select my floating text game object, we can see underneath our floating text a text message

11:03.560 --> 11:06.600
appear and it says none text message basically empty.

11:06.600 --> 11:11.560
So what we need to do now, we do know the text mesh is attached to this text game object.

11:11.560 --> 11:14.720
So we need to select this text and then drag it right there.

11:14.720 --> 11:16.680
Basically this text game object.

11:16.680 --> 11:21.680
And we can see now we have text and the text mesh component as you can see.

11:21.720 --> 11:23.560
And we are ready to do that.

11:23.560 --> 11:26.520
So let's open up our script because we have the reference.

11:26.520 --> 11:29.120
And let's move over to this start function.

11:29.120 --> 11:32.640
So in this start of the game we're going to choose a random number.

11:32.640 --> 11:38.160
For a random number we're gonna use this random dot range function.

11:38.160 --> 11:41.160
So we're going to use this random dot range function.

11:41.160 --> 11:42.640
And this over here.

11:42.800 --> 11:43.840
So make first bracket.

11:43.880 --> 11:47.920
It's going to take the minimum inclusive and the maximum inclusive.

11:47.920 --> 11:50.960
So I'm going to pass or I want to start from one.

11:50.960 --> 11:54.140
So that's that's why I'm going to pass as a first argument.

11:54.140 --> 11:54.580
One.

11:54.740 --> 11:55.220
And.

11:55.780 --> 12:01.020
As a second argument I'm going to pass one zero, one and then close that up with semicolon.

12:01.020 --> 12:07.100
So this random dot range function over here I'm going to pick up a random number between 1 and 1 zero

12:07.140 --> 12:07.500
one.

12:07.500 --> 12:12.380
And we definitely definitely know that this 101 will not be included.

12:12.380 --> 12:15.460
But the 100 will be and this one as well.

12:15.460 --> 12:18.700
So this number can be between 1 and 100.

12:18.740 --> 12:20.060
It can be 99.

12:20.060 --> 12:22.500
It can be 100, it can be 54.

12:22.540 --> 12:23.620
Anything like that.

12:23.620 --> 12:29.500
So this random dot range function is just going to pick up a random number between 1 and 1 zero one.

12:29.500 --> 12:31.900
So what we're going to do whatever we get.

12:31.940 --> 12:34.500
Or this random dot range function pick up.

12:34.540 --> 12:37.780
We're going to store that number into a another variable.

12:37.820 --> 12:40.580
Or you can say into a another container.

12:40.580 --> 12:42.340
And that's going to be an integer.

12:42.340 --> 12:42.740
Why.

12:42.780 --> 12:47.260
Because this one we do know integer zero, one, two three, four and 100.

12:47.380 --> 12:49.540
And all of these are integer numbers.

12:49.540 --> 12:55.210
So that's why we need to put it in a container called integer container or integer variable.

12:55.210 --> 13:00.450
So I'm going to create an int for referencing the type of the variable.

13:00.450 --> 13:01.490
And we have to name it.

13:01.490 --> 13:04.730
So I'm going to call it something like random number.

13:04.730 --> 13:08.370
Or we can simply call it a number as well.

13:08.370 --> 13:10.250
And let's set it equal to this.

13:10.250 --> 13:16.570
So this number over here going to be a random number between between 1 and 1 zero one.

13:16.570 --> 13:20.650
Or it's going to depend upon what this random dot range function pick up.

13:20.650 --> 13:24.570
So this let's suppose this random dot range function pick up 60.

13:24.570 --> 13:27.730
So this over here number just going to be 60.

13:27.770 --> 13:30.570
As you can see by directly we setting it.

13:30.570 --> 13:35.730
And after doing all of this thing what we have to do we need to update the text as well.

13:35.770 --> 13:41.570
Basically we need to change this 100 text with 60 because that number is going to be 60.

13:41.570 --> 13:46.050
So what we're going to do over here, we're going to move over to that text message because we have

13:46.050 --> 13:47.650
the reference as you seen.

13:47.650 --> 13:52.710
And then we're going to access the text and we're going to set the text equal to this number, and we're

13:52.710 --> 13:54.550
going to close that up with semicolon.

13:54.550 --> 13:55.950
And we get some error.

13:55.950 --> 13:57.870
We just get a little bit error.

13:57.870 --> 14:00.110
And it says in true in string.

14:00.110 --> 14:04.590
Basically this over here number is an integer value and this one is a string.

14:04.590 --> 14:06.510
So we need to convert this integer.

14:06.750 --> 14:08.590
This number is an integer value.

14:08.590 --> 14:11.590
So we need to convert this one into a string.

14:11.590 --> 14:15.870
And in order to convert that we need to use this dot two string function.

14:15.870 --> 14:17.390
And then make first bracket.

14:17.390 --> 14:21.350
And we can just press down Ctrl s in order to save our script.

14:21.350 --> 14:23.270
And we can just move over to unity.

14:24.670 --> 14:26.350
So just wait for to compile.

14:35.510 --> 14:37.430
And let me explain one more time.

14:37.630 --> 14:44.190
So firstly we grabbing the reference as you can see and I really apologize.

14:44.390 --> 14:47.830
Then we're just going to take space and then accessing the text.

14:47.830 --> 14:49.660
And we're setting sitting equal to number.

14:49.660 --> 14:53.220
Basically we're just going over to this text mesh component.

14:53.220 --> 14:57.180
And then we just accessing this text which is 100 as you can see.

14:57.220 --> 14:59.020
And we're setting equal to number.

14:59.020 --> 15:04.940
And let's suppose this number or this number just be something like 65.

15:04.940 --> 15:07.300
So this gonna be over here 65.

15:07.300 --> 15:13.700
So that's why this text dot text just gonna be 65 right away because we're setting it as you can see.

15:13.700 --> 15:20.180
So this text right over here just gonna be 65, but it's just gonna be a random number, as you can

15:20.180 --> 15:20.540
see.

15:20.780 --> 15:26.740
Uh, basically as you seen, we have used that random dot range function in order to do that.

15:26.740 --> 15:30.340
So let's have a look by now and make sure you just drag the reference.

15:30.540 --> 15:34.340
And we will go to overrides and then click on apply all as well.

15:34.340 --> 15:38.420
So now let's click on this play button in the top in order to see that.

15:44.500 --> 15:46.180
So just wait for to compile.

15:47.220 --> 15:50.240
And as you can see, it became 42.

15:50.240 --> 15:52.080
And the animation just looping.

15:52.120 --> 15:55.160
Basically it's just going over again and again.

15:55.320 --> 15:56.960
The animation clip is playing.

15:56.960 --> 16:02.040
So let's get out of play mode and we need to uncheck the loop time of this animation clip.

16:02.160 --> 16:06.280
So to do that let's go to project tab assets and then animation.

16:06.440 --> 16:08.600
And I have the floating text.

16:08.600 --> 16:12.480
So let's select that and I'm going to uncheck this loop time in Inspector.

16:12.480 --> 16:18.320
And now if we just click on this play button you will see the animation will be played just one time.

16:21.480 --> 16:24.280
And the number is just going to be a random.

16:24.880 --> 16:28.520
As you can see as soon as it started it's now 23.

16:28.520 --> 16:33.040
And if we just get out of play mode and then click on this play button in the top, you're going to

16:33.040 --> 16:39.040
see a different number by now because we're using that random dot range function.

16:40.760 --> 16:41.760
So just wait.

16:42.120 --> 16:45.480
And as soon as the game started now we can see 52.

16:45.720 --> 16:49.670
But we also need to destroy this number after some period of time.

16:49.670 --> 16:55.510
And we do know that we're just completing the animation clip of this floating text after one second.

16:55.510 --> 16:56.550
And let me show that.

16:56.550 --> 16:58.110
So I'm gonna get out of play mode.

16:58.110 --> 17:03.630
And if we select Floating Text and move to animation tab, basically the child one, and we can see

17:03.670 --> 17:06.670
after one second we're just completing our 60 frame.

17:06.670 --> 17:09.670
We just completing the animation clip as you can see.

17:09.670 --> 17:15.550
So after this period of time we need to destroy this floating text game object as well.

17:15.670 --> 17:17.230
So we need to destroy that.

17:17.230 --> 17:19.310
So to destroy let's move to script.

17:19.310 --> 17:21.790
And we're going to move over to this start function.

17:21.790 --> 17:24.390
So in this start of the function we're going to destroy.

17:24.430 --> 17:28.950
So we're going to use this destroy function in order to destroy that as a first argument.

17:28.950 --> 17:31.630
It's going to take the game object that you want to destroy.

17:31.670 --> 17:37.070
So we're going to pass this dot game object basically means it's just referencing itself.

17:37.070 --> 17:44.030
And the second thing we need to specify the time in after what x amount of time that you just want to

17:44.030 --> 17:44.590
destroy.

17:44.590 --> 17:48.130
So I'm going to pass for something like one app, basically one second.

17:48.130 --> 17:52.050
So I'm going to pass one app and let's close that up with semicolon.

17:52.770 --> 17:59.290
And so after this amount of time this game object just going to destroy itself as you can see.

17:59.330 --> 18:05.770
And we can just put this line of code in the bottom by holding down alt and using down arrow key.

18:05.970 --> 18:09.730
Or you can just use up arrow key in order to move this up.

18:09.730 --> 18:11.010
But I'm gonna move this down.

18:11.010 --> 18:16.090
So that's why let's press down Ctrl s to save our script and let's move to unity.

18:16.090 --> 18:21.250
So after one second you will see this takes this floating text will also be destroyed.

18:30.610 --> 18:31.850
Now let's have a look.

18:31.890 --> 18:35.330
So I'm going to click on this play button in the top to play our game.

18:40.410 --> 18:42.850
So after one second it will be destroyed.

18:44.730 --> 18:50.440
So as you can see, it does get destroyed once it's, uh, the time is over.

18:50.440 --> 18:52.000
So let's get out of play mode.

18:52.000 --> 18:57.520
And what we're gonna do instead of showing by default, we're gonna delete this one from our hierarchy

18:57.600 --> 19:03.480
as well as in the scene view, because we only want to spawn once this enemy game object takes damage.

19:03.480 --> 19:07.800
So we're going to select that and we're going to destroy it or delete it now.

19:07.800 --> 19:13.840
And let's open up our enemy script where we're taking damage from our player game object.

19:13.840 --> 19:15.920
So let's select the enemy one game object.

19:15.920 --> 19:18.920
And let's open up the enemy script by double clicking on it.

19:19.440 --> 19:25.480
Uh, firstly, in order to spawn that, we need a reference to our floating text game object as we know.

19:25.480 --> 19:27.720
So we need a reference.

19:28.040 --> 19:32.000
Uh, so let's go to the top of our class and let's grab the reference first.

19:32.000 --> 19:34.080
So I'm going to make it somewhere over here.

19:34.080 --> 19:35.960
So let's make a public.

19:36.280 --> 19:39.920
And that floating text game object itself a whole game object.

19:39.920 --> 19:44.640
So we need to type this game object because that itself a whole game object.

19:44.660 --> 19:49.780
and we can call this one to something like floating text game object or prefab.

19:49.780 --> 19:51.700
So let's call it prefab instead.

19:52.100 --> 19:54.700
And now let's close that up with semicolon.

19:54.700 --> 20:00.100
And make sure once you move to unity drag the reference in this current corresponding slot.

20:00.140 --> 20:04.540
And now let's go over to take damage function basically where we're taking damage.

20:04.540 --> 20:07.460
So we're taking damage over here as you can see.

20:07.460 --> 20:11.580
So after taking damage we also want to spawn that floating text.

20:11.580 --> 20:16.580
So to spawn we do know we're going to use this instantiate function and make first bracket.

20:16.580 --> 20:20.500
So as a first argument it's going to take the game object that you want to spawn.

20:20.500 --> 20:24.540
So in our case that floating text game object or that prefab.

20:24.540 --> 20:28.220
So we're going to pass as a first argument floating text prefab comma.

20:28.260 --> 20:30.140
Second thing it's going to take the position.

20:30.140 --> 20:32.260
So we're going to pass transform dot position.

20:32.300 --> 20:35.580
It basically means the center position of our enemy.

20:35.820 --> 20:38.780
And comma third argument is going to take the rotation.

20:38.820 --> 20:42.860
So we're going to pass quaternion dot identity basically means no rotation.

20:42.860 --> 20:45.050
And let's close that off up with semicolon.

20:45.050 --> 20:47.770
And now we're going to press down Ctrl S to save our script.

20:47.770 --> 20:49.010
And let's move to unity.

20:49.490 --> 20:56.570
So uh, so once this anime GameObject takes damage you will see that floating text just gonna spawn.

20:56.570 --> 21:01.530
And we do know it's gonna be a random number between 1 and 1 zero one.

21:02.090 --> 21:04.690
So now we need to drag the reference.

21:04.690 --> 21:10.650
And we can see underneath our anime script floating text prefab just pop up and it says none game object

21:10.650 --> 21:11.610
basically empty.

21:11.610 --> 21:13.890
So what we need to do it over here.

21:13.930 --> 21:17.810
We basically need to drag the floating text prefab game object here.

21:17.810 --> 21:22.890
So let's go to project App assets and then prefabs folder basically where we drag it.

21:22.890 --> 21:25.410
And I have the floating text game object over here.

21:25.410 --> 21:29.250
So I'm going to select that and drag it over to this corresponding slot.

21:29.290 --> 21:31.690
Now we can see we have the floating tags.

21:31.690 --> 21:34.730
As you can see underneath your anime script.

21:35.090 --> 21:38.530
And let's click on this play button by now and let's have a look.

21:38.530 --> 21:43.710
So once this anime game object is gonna take damage, that floating text just that's going to spawn

21:43.710 --> 21:48.910
right away, and it's just going to be a random number between 1 and 1 zero one.

21:48.910 --> 21:50.830
So let's have a look on this.

21:51.190 --> 21:53.270
So I'm going to attack on this enemy.

21:53.310 --> 21:57.230
As you can see it's became 100 then six and then 58.

21:57.230 --> 21:58.950
And we can just get out of play mode.

21:58.950 --> 22:01.790
And we can click on this play button to play our game.

22:01.790 --> 22:07.870
And we can take a look on that one more time, basically if it's working fine or not.

22:07.870 --> 22:10.030
So we're going to take a look on that.

22:10.030 --> 22:14.030
So let's click basically shoot on this enemy game object.

22:14.630 --> 22:18.430
And we can see 1441 and 20.

22:18.430 --> 22:20.310
So we can see a random number.

22:20.310 --> 22:24.150
So adding floating text makes our game a lot of cool.

22:24.390 --> 22:26.070
So I'm going to get out of play mode.

22:26.350 --> 22:32.750
So you can just use that same principle in order to anything that you would like to go with.

22:32.790 --> 22:38.030
And you can just choose a different color of that font as well before you spawn it.

22:38.030 --> 22:39.230
You can do that.

22:39.550 --> 22:43.190
Uh, I hope you get the idea that how you can do this.
