Let's create the floating text.
It's going to pop up from this anime.
Anime.
One game.
Object or anime.
Once this anime.
One game object.
Takes damage.
So we need to create that.
To create that, we're going to move over to.
Hierarchy.
Let's right click, then create an empty game object.
And we can call this game object to something like a floating text.
Uh, let's call it text instead.
Uh text.
And then what we're going to do, we're going to move over to Inspector, then transform, right click
on it and then reset.
And we're going to press down F in order to focus on it.
And what we're going to do.
We're going to add the text right over here.
To do that select your text in the hierarchy.
Then go over to Inspector.
Then click on this add component and find over here by typing Text Mesh.
So I'm going to type text mesh.
We need to type text mesh and it's going to pop up.
Select this one text mesh.
So just click on it in order to select it.
And what we're gonna do, we're gonna move over to this text field and text.
As you can see, it's totally blank.
So we're going to put 100 something like that.
And now we are not able to notice our text in in the scene view as well as in the game view.
But it kind of seems blurry.
So what we basically have to do, we need to make the this character size to something around 0.1.
And after doing that, make sure you go over to font size and just increase that.
So I'm going to increase with something like 100.
Or by now we can able to see the blurry is gone.
And and basically the weird thing is gone by now.
And instead of making font size little bit bigger, I'm going to make it something around 6060 I guess.
Pretty much cool number as you can see.
And we want to choose this text should be middle in the middle.
So that's why we're going to move over to alignment.
We're gonna select center and a font style.
We're gonna choose bold and we need to put it a put it in the center.
So let's click on this anchor and it says upper left.
So just click there and then choose this middle center.
And as soon as we have chosen we can see by now the text is center.
So we will have the animation something like this text firstly will go up and over time it's gonna fade
out.
So we can simply create the animation.
But it's gonna give us weird movement or weird animation.
It's not gonna be fine at all.
So that's why we need to create an empty parent game object first, and then we need to make this text
game object child of that game object.
Basically, we need to create an empty parent game object.
To do so make sure you go to hierarchy.
Right click or hit this plus icon.
So let's right click.
And we're going to create an empty game object.
And we will call this game object to something like floating text.
So let's call it floating text.
Sorry.
Floating text.
Or we can simply call floating text as well.
I'm going to call this floating text.
And let's go over to Inspector Transform.
Let's right click on it reset.
And I'm going to choose N gizmos for it.
Something like this.
And now what we're going to do.
Or we can remove these gizmos.
So I'm going to select click on this none in the top right.
And now I'm going to select my text game object that we created.
And we're going to drag it on top of this floating text game object.
And now if we select our floating text game object and then select this move tool and then move around
in the scene view, we can see the text game object also going with it.
Why?
Because the text we just made it a child of this floating text game object, as you can see.
And make sure you select your text game object.
Then go over to Inspector, then transform.
Right click and then reset.
So it's going to reset the position as the position of our floating tails.
And now we can create the animation inside this text game object instead of doing inside this floating
text.
So we can do that.
So I hope you get the idea that how you can do it.
And now what we're gonna do, we're gonna create an animation.
So we're gonna have the animation really apologize.
Just wait a moment.
So just wait a moment.
Now it's fine.
So what we will do, we're going to create the animation.
We're not going to do it into this game object.
We're going to do it inside this text game object.
So that's why we just created an empty parent game object first.
And then we just made this text game object child of it.
So we're gonna create inside this text.
But before I do I want to change the font.
So to change in order to change the font we're going to select our text game object underneath our floating
text in the hierarchy.
Then go over to Inspector, then, uh, then make a text mesh component.
And we will move over to font size.
And we're going to make it a little bit small.
But before we do let's change the font.
And we can see in the bottom says font.
And it says none font.
So we can drag any font if we have it.
Or we can simply click in the right section and we can choose the font.
And if you have your font in your project, then you can just head over to your project tab, then assets,
and then uh, I have it inside this fonts folder.
So I'm going to select that and let's select the first font or any of them.
Then drag it over to this font slot.
And as soon as we drag it by now we can see this, uh, this just change immediately the font.
And now by now, we can, uh, create the animation.
So I'm going to leave the font size with 60.
Let's leave that.
But once we're going to make the animation we just want to firstly we will move it up direction in the
Y, in the up direction a little bit and over time we are just gonna make this fade out.
To do so, we're going to select our text game object underneath our floating text in the hierarchy.
Then go over to the animation tab and animation tab.
And let's click on this create button in order to create the animation.
So we will go to assets first.
In the top we can see assets and in assets.
As you can see we already created a folder called animation.
So we're going to open that up by double clicking on it.
And let's create a sub folder for our floating text.
So let's right click and then new folder.
And we can name this folder to something like other animation or animation.
Something like that I'm going to call other underscore animations.
Let's call it something like that.
Any animation let's call it animations, and let's open up this folder by double clicking on it, and
we have to name the animation.
So I'm going to call it something like floating uh, floating uh text animation underscore animation
animation something like that.
And now click on that save button in order to create the animation.
So now what we're gonna do, uh, we will move over to our animation tab and make sure you select your
text GameObject in the hierarchy, not the parent one which is floating text.
So we need to select the child one.
Then go over to animation tab and then click on this red button in order to record your animation in
your animation tab.
So we will move over to something like 160 frame, like something like one second.
As you can see right over here.
And what we're gonna do now, we're gonna select our text and we will move it up a little bit, something
like this much.
Uh, and this much seems pretty much cool.
Let's move it up a little bit more.
And if we just go ahead in animation tab and then click on this play button, we can see the animation.
And over time I also want to increase the font size.
So that's why I'm gonna move over to one second or 60 frame.
Then I'm then I will select my text game object underneath floating text.
Let's go over to Inspector then text mesh component.
And I'm gonna make the font size something like 100.
And over time I want to basically I want to fade out.
So what we will do, we will go over to color in this text based component in the bottom.
Then click there.
And in the bottom you can see a which is set to 255.
So we're gonna make it zero.
Or we can simply drag it like this.
Uh, so it's automatically just gonna fade out.
So if we make it zero and now if we go ahead and then click on this play button in.
Sorry.
We just we have done some mistake.
Um, I guess instead of fading out.
So let's set back to, uh, to five five instead of doing that.
So we're going to set back to two, uh, five five, something like that.
And this seems pretty much cool.
So we can just live with that.
And now it seems pretty much fine.
So if I just go ahead and then click on this play button, we can see that animation is just playing
over again and again.
And we can notice that.
And I want any y a little bit up more.
So in the y I'm going to drag it something like this much.
And if we click on this play button so it seems pretty much fine.
And once you are satisfied then you can just click on this red button to capture your animation.
Uh, to capture your animation once you are satisfied.
And if you don't click on this red button, then it's automatically gonna capture the animation, so
you don't need to worry about anything like that.
And now what we will do, we will make this floating text game object a prefab.
Make sure you basically don't select the child one.
Basically select the parent one and then make that one a prefab.
So we will have the copy and we can spawn wherever we need.
So we're gonna spawn it from this anime game object.
Once it starts taking damage then we're gonna spawn it.
So that's why we're gonna make this floating text a prefab.
To do so, we will head over to our project tab, then assets folder, and then prefabs folder, and
we will select our floating text in the hierarchy.
And let's drag it over to that Flow Prefabs folder in order to turn it into prefab.
Now we turn it into a prefab.
And if we just go ahead and then click on this play button in the top, you will see this floating text.
Just gonna, just gonna play that animation clip, which is which we created earlier inside that text
game object as using.
So that animation just gonna play over again and again.
So we need to stop doing that.
Basically we need to uncheck the loop time of that animation clip inside our floating text underscore
animation that we created recently.
So before we do it let me show you.
So if we start our game we can see this animation is playing over again and again.
And we need to stop doing this.
So that's why we're gonna get out of play mode and we will move over to our project tab then assets.
Sorry.
We will move over to our assets folder, then animation folder in animation folder.
As you can notice we created this other underscore animation folder recently.
So we're gonna open that sub folder by double clicking on it.
And we can notice our floating text floating text underscore animation clip.
And we're going to select that.
Then go over to Inspector.
And we're going to uncheck the loop time so that now.
So by now the floating text basically that animation clip not gonna play over again and again.
So let's click on this play button in the top in order to play our game.
And let's take a look on this.
So the animation will be fine by now it's not gonna play over again and again.
It's gonna play one time and that's all.
And we also need to delete this floating text in the hierarchy for now.
We need to spawn it when we need it.
So before we do it, let's have a look so we can see that the animation is not looping at all.
So the animation not looping not looping.
And that's fine.
So we will get out of play mode and we will select our floating text in the hierarchy.
and we're gonna delete it because we don't need it, but when we need it.
Once this anime one start taking damage, then we're gonna spawn this floating text for.
So for now, we're gonna destroy that.
Basically, we're gonna delete it from the hierarchy.
As well as in the scene view.
So we're going to select our floating text in hierarchy.
And let's press down delete in order to delete that.
And now we're gonna spawn it when.
Our enemy one GameObject start taking damage.
So we're gonna do that.
So let's do it over here.
So firstly I'm going to select my enemy one game object in the hierarchy.
And let's open up the enemy.
One script by double clicking on on it.
And what we will do we're gonna spawn it to spawn it.
We need a reference of that floating text prefab that we created.
Basically, if we move over to.
Unity editor, then move over to this project tab and then assets and then prefabs folder, we can see.
Our floating text game object is over here, so we need a reference of this floating text game object.
Then we can spawn it.
So let's grab the reference first.
So we will move over to script.
Let's go to the top of our class and let's make it over here.
So let's make a serialized field.
Serialized field private uh private.
And the game object we are looking for is a floating text prefab or that floating text game object.
So that floating text itself, a whole game object.
So that's why we need to type this game object type variable.
And we can call this one to something like floating floating text prefab.
So let's call it floating text prefab.
And then close that up with semicolon.
And we're going to press Ctrl S to save our script.
And now let's move over to unity.
So as soon as our script just gonna compile underneath our enemy one script, we will be able to notice
a, uh, you can simply say, uh, a message.
Just gonna, uh, sorry.
Underneath our enemy won't skip a file.
Just gonna appear and it will say floating text prefab.
So what we need to do there, we basically need to select this floating text prefab game object.
And we need to drag it in that slot.
So we will have the reference.
And after that we can spawn it when we need that.
So just wait a moment and you will see.
So just wait a moment.
So now if I select my enemy one GameObject in the hierarchy and then go over to Inspector.
So just wait.
We can see underneath our enemy one script.
In this health title, we can see that we have floating text prefab and it says non game object.
So we will simply select that floating text prefab game object from our prefabs folder.
Then drag it over to this slot.
Now we can see that we have the floating text game object, and we are ready to spawn it to spawn it.
Let's open up our anime one script and we're gonna spawn it when we take damage.
So basically we will move over to our Takedamage function over here.
As you can notice, we taking damage.
We playing the heart animation clip.
So in that moment we need to spawn it.
And we do know that in order to spawn it we need to use this instantiate function and this instance
function as a first argument.
It's going to take the game object that we want to spawn.
So in our case it will be floating text prefab.
And we do know that in floating text prefab we just drag it that floating text as you seen in Inspector
Comma.
Second thing, it's going to take the position.
So we're gonna spawn it from our center position of anime one game object so we can simply pass transform.position
means that enemy position, enemy position, or current current position of that enemy one game object
and the third argument is going to take the rotation.
So we're going to pass our quaternion dot identity.
It's basically means no rotation.
So let's pass quaternion dot identity.
And let's close that off with semicolon.
So now we spawning this floating text prefab at this position with no rotation.
As you can notice right over here.
And now we're going to press down Ctrl S in order to save our script.
And now let's move over to unity.
So as soon as our ship just gonna compile underneath our enemy one script.
Sorry, not underneath our enemy one script.
Basically, as soon as we're gonna damage our enemy, one game object, you will see that floating text
prefab just gonna spawn from the from that, uh, basically from this anime one game object.
Uh, so just wait a moment and you will see that.
So now it's, uh, fine.
So let's have a look.
So I'm going to click on this play button in the top in order to play my game.
And let's take a look on this.
So just wait a moment.
And now if we just get closer to this anime one game object and damage it.
So we can see by now.
As you can notice, the floating text prefab just getting spawned from this anime game object center
position.
Instead of spawning that over here center position, we're gonna spawn it something like top of this
anime, one game object hat or something like from chest so we can spawn it.
So let's create a point in order to spawn spawn that basically this floating text prefab from that position.
So let's get out of play mode.
So let's create a point somewhere over here.
So we will select our enemy one GameObject in the hierarchy.
And let's create an empty game object inside this enemy point game object.
So let's right click on it.
Let's create an empty game object.
And we can call this GameObject to something like Spawn Point.
So let's call it Spawn Point.
And let's select this spawn point underneath our enemy one GameObject in the hierarchy.
And let's move it somewhere around here.
And if you want to choose an gizmos then go over to Inspector.
Click here and we're going to choose this, uh, this green one, something like that.
So from this position we want to spawn it.
So we need a reference of this spawn point.
Then we can just spawn from this position.
So let's grab the reference first basically this position.
So let's open up our enemy one script by double clicking on it.
Let's go to the top of our class and let's grab the reference of that position.
So let's make a serialized field.
So let's make a serialized field a private.
And we're looking for position.
So we need to type this transform which is responsible for position rotation and scale.
And we can call this one to something like spawn point.
Let's call it spawn point.
And let's close that up with semicolon.
And we're going to press down Ctrl S to save our script.
And now let's move over to unity.
So underneath our enemy one script and another filter's gonna pop up says Spawn Point.
So what we need to do there, we basically need to select this spawn point underneath our enemy one
GameObject in the hierarchy.
And we need to drag it over to that slot.
So we will have the point.
And after that we can just spawn it from that position.
So just wait a moment.
And now as soon as our enemy one square enemy.
One script just gets compiled.
We can see spawn point and it says None Transform.
So we will select our spawn point and drag it over to that field.
Now we can see we have the spawn point and we are ready to spawn it from this position.
So let's move over to our enemy one script and let's move over to our function, in which function we
spawning basically over here.
As you can notice, we spawning this floating text prefab at this position.
So instead of spawning from that transform.position basically means current position of that enemy one
game object.
Instead of spawning from that, we're going to pass our spawn point spawn point dot position as we created.
Now this floating text prefab right over here, it's gonna spawn from this position which spawn point
dot position.
So and we do know that spawn point in, we just drag it that spawn point into our spawn point fail so
that this floating text prefab just gonna spawn from this position, which is spawn point dot position
with no rotation, as you can notice.
And now we're gonna press down Ctrl S in order to save our scape.
Let's move over to unity.
So we will see by now that a floating text prefab game object or that floating text game object just
gonna spawn from this spawn point that we created and make sure you drag it your spawn point to spawn
point fill, so you will have the reference of the position, and after that you can able to spawn it
from that position.
So now script is a script, compilation is done.
And if we just go ahead and then click on this play button in the top in order to play our game and
start damaging our enemy one game object, you will notice that a floating text prefab just just gonna
spawn from this spawn point.
So let's get closer to this anime.
One game object and if I damage it, we can see by now that is spawning from over here from this spawn
point.
As soon as.
Sorry.
As soon as we just damaging our enemy one game object as you can notice.
So we can drag our this position a little bit up.
So what we can do, we can get out of play mode.
And let's select this spawn point and let's drag it a little bit up.
Something over here or top of this anime -- game object head head position.
So now that's fine.
And make sure you select your anime one game object.
Then go over to Inspector Overrides and then apply all.
If you turn it your anime one into a prefab, then you can do that or else you need to.
You don't need to do.
But the problem is that if we go ahead and then click on this play button, you will see that, uh,
those, uh, floating takes a game object is spawning, but it's not getting destroyed it after some
period of time.
So we need we also need to destroy it.
So to make our game a game clean.
Clean or over time our frame rate just gonna shrink down.
Or simply you can say the game will be laggy.
So that's why game will be laggy because it's gonna hold to many game objects.
So that's why the frame rate is just gonna be less so over time.
So that is the reason.
So if I damage my enemy one game object, we can see, uh, this 100 just pop up basically that, uh,
uh, that floating takes prefab.
But the problem is that we still able to notice our floating text in the scene view.
And if we move over to hierarchy, we can see we have the floating text clone game object.
So we also need to destroy this floating text after some period of time.
So what we will do, we will get out of play mode.
Uh, so to destroy after some period of time, we need to check after how much time we just completing
the animation clip, so we will.
For that we will head over to our project tab.
Then we will move over to assets folder, then prefabs folder and we will open up the floating text
prefab by double clicking on it.
And if we select our text underneath our floating text GameObject in the hierarchy, then go over to
animation tab.
We can see after one second or 60 frame we just completing the whole animation clip as you can notice.
So after this amount of time, basically after one second we need to destroy this floating text game
object right away after after playing the animation clip completely.
So after this much of time, we need to destroy that.
So to go back in hierarchy we can see back arrow.
So let's click there in order to go back into this in view.
So after one second we need to destroy that floating text prefab game object.
So we will open up our anime one script.
So we is spawning this floating text prefab.
As you can notice right over here at this position with no rotation.
So after spawning that we're going to store it into another game object.
That floating text prefab that we spawn it.
We're going to store it into another container.
And the container is just going to be a game object type container.
Why?
Because this floating takes prefab itself a whole game object.
So that's why we need to put it a container or a variable, which should be a game object type.
So we need to type this game object.
And then we have to name the container or the variable where we want to store it.
So we're going to call it something like tame floating text prefab floating text prefab like that.
We're going to call it.
And then let's set equal to this.
So firstly what we're doing we just spawning this floating text prefab at this position which is spawn
point dot position with no rotation.
And after that we're just taking that what we spawned.
So we spawned this floating text prefab.
And then we're storing into this float atom floating text prefab GameObject.
Basically we are taking this floating text prefab, what we spawn it and we're storing into this temp
floating text prefab GameObject.
So what we need to do now we need to destroy this temp floating text prefab GameObject after one second.
Basically where we store it our floating text prefab.
So we also need to destroy it.
So that's why after spawning, we're going to use this destroy function in order to destroy as a first
argument, it's going to take the game object that we want to destroy.
So we're going to pass this temp floating text prefab basically where we store it our other floating
text game object.
And the second thing we can specify the time after how much time we want to destroy it.
So as you've seen that after one second it's completely it's just completing the whole animation clip.
So that's why after one second we want to destroy this team floating text prefab or where we store that
floating text prefab game object.
So we're going to destroy.
So we simply destroying the container where we storing or we in which variable we storing.
We just destroying that as well.
So after one second we want to do so.
That's why we're going to put one f.
Or you can simply say after one second.
So just wait.
It's a little bit lagging.
So we're going to put one F and then sorry.
So this will be one f.
And let's close that up with semicolon.
And we're going to press down Ctrl s in order to save our script.
And now let's move over to unity.
So you will see as soon as those floating takes prefab just gonna spawn from this enemy one GameObject
spawn point.
After one second you will see those will be destroyed because firstly we spawning it and after recording
it, we just storing that into a floating text prefab container as you've seen inside our script.
So after one second we also destroying the container where we're storing that.
So we are destroying as well.
Uh, or you can simply say we destroying the floating text prefab that we spawned after one second.
So just wait a little moment.
Once our script compilation is done, we can just check that out by clicking on this play button in
the top in order to start our game in order to check it.
So just wait a little moment, uh, for my slow system.
So that's why it's taking a little bit longer time.
And now if we go ahead and then click on this play button and then damage this enemy one game object,
you will see.
So as soon as we're gonna start a start damaging this enemy one, it's gonna spawn that floating text
prefab and that floating text takes prefab game object just gonna destroy itself after one second.
So let's take a look on this.
So firstly we're gonna get closer to this anime one game object.
And if we start damaging our enemy one, we can see it's spawning.
And after one second we can notice that that floating takes prefab just destroying itself after spawning.
Basically after completing the whole animation clip.
And we can notice in this in view as well as in the hierarchy.
So if we move over to hierarchy, we cannot see any floating text prefab or floating text clone, as
you can notice in the hierarchy as well as in the scene view.
So after one second it's just getting destroyed itself.
And you can notice in the hierarchy as well as in the scene view as well as in the game view.
So I hope you get the idea that how you can do it and I'm gonna get out of play mode.
So I hope you get the idea that how you can do it.
So that's fine.