In this video, we'll design the animated stars on the Pickups.
This will make them stand out in the level,
but also indicate the player that they can collect these gems.
We're going to use a technique called Particles to achieve that.
Particles allow you to create all kinds of visual effects, to represent chaos,
to create flames, to also create these sparkles here,
and to very quickly change the look and feel of their animation.
To get started, open the Obstacle Course 2D Part 2, Pickups, pickup.tscn scene,
which I have here, and we'll start by adding a new Particles node.
Press Control A and add a Particles 2D node,
the last one, not the CPU Particles 2D.
The Particles 2D node has more features than its CPU counterpart.
The CPU Particles 2D node is designed for compatibility with older devices.
The Particles 2D node will spawn small Sprites
and scatter them and animate them over time.
To get started, we want to give the Sprite a texture.
So we go to the Textures category in the Inspector,
and right-click on Texture, quick load while looking for sparkle.png
so little star, you can see the stars appear there.
They are stacking up, currently.
They are not being animated because
while lacking the parameters to do so.
To change the animation of your Sprites,
you want to expand the process material in the Inspector
and there click, and we're going to create a new Particles material.
This is a built-in resource that gives you many parameters to create your Particles.
If you create a Shader material instead,
you can make completely custom animations using code.
But for now, we're going to click our newly created material to expand it,
and we're going to start working on the many properties in there.
I'm not going to cover them all because as you can see, there's a lot of them
and they depend a lot on the precise effect that you create.
We're going to only cover the ones that we need here.
First is the Emission Shape.
Currently, all the Sprites spawn at the same position,
but we want to scatter them around the gem.
We're going to change the shape from point to Sphere,
and then we have to change the radius
so we can increase that to see that the stars
start to appear in different positions.
The shape is a sphere rather than a circle
because the underlying code is compatible with 3D.
The next thing we want to do is perhaps, change the scale of these Particles.
We're going to go down to the Scale category
and we're going to lower it maybe, half that should be fine.
Yes, maybe 0.4, okay.
Now, the sparkles look a bit better.
The next thing that we want is for them...
Well, two things.
First, we want to move the particles up,
so we're going to use the Move tool in the toolbar and Shift, click and drag
to center them on our little gem
just so they're not spawning below the gem, right.
With that, we want to make the stars move up, instead of down.
To do so, we can use the gravity.
Currently, it's making the stars accelerate downwards.
We want to make them go up, so we're going to use a negative value.
You can say minus 100 on the vertical axis,
you can see how already you could use that for healing effects
and games for dust coming off the floor, you name it.
But for now, we're going to continue with a bit of variation
to the star's angle and the angular momentum,
because right now, they are all aligned and it looks really off.
So we're going to expand the Angular Velocity.
It's basically the angular momentum of the stars and we can increase it.
For example, we can say velocity it's in degrees, so 180, right?
It's going to make them all turn.
And then we can crank up the random slider to randomize the speed.
A value of Velocity Random of zero,
means that all the particles have the same angular momentum, right?
But if you crank this up to one,
they will all have a random value between 0 and 100 and 80 degrees
per second rotation speed.
You can play a bit with the slider and choose something that looks good to you.
The next thing that I like to change is animating the scale of the stars
because it's the next thing that looks off to me.
You can see how they disappear.
Instead, we want them to either fade out
or another technique is to animate their Scale.
We can go back down to the Scale category
and you can see the Scale Curve property.
This allows us to use Curve to animate the scale of particles over time.
Click the Scale Curve to create a new Curve Texture
and then click the result to get your curve in here,
then click the Curve to edit it.
It pops a little editor in which you can see the curve, right here.
Right now, the scale of these particles is constant over time.
When it writes one, it's a multiplier, so it's 0.4 times what's on the Curve here.
It's constantly at 0.4, the texture scale.
Now, what happens if we lower one of these points?
You can see the stars start to grow up to this maximum
at the end of their lifetime when they disappear, right?
If we lower this part of the Curve,
you can see that now, the stars are not as big,
so you can use the Curve as a way to control the maximum scale too.
Now, what I want here is the star to go up and scale
and then to scale back down and disappear.
We can add a new point to the curve to do so,
so right-click somewhere on the Curve and select Add Point.
Then I'm going to move that point up and I'm going to lower the last one
so you can see now, the stars are scaling up
and then back down as they disappear
and you can lower your Curve down to zero for them to disappear completely.
When you select one of these points, you can see the blue handles that appear.
You can click and drag on these handles can be a bit tricky.
But you can use that to control the Curves orientation, like so.
Anyway, for now we have a Scale that doesn't look too bad.
I think that I want to lower the Scale
or perhaps play with the randomness a bit.
Now, the problem is the way the randomness works with the Scale is it randomizes it
between your Scale Value and the default Scale of the Texture.
It's a bit confusing, actually.
We are going to lower the Particle Scale, 2.3
and as I told you, the Scale Curve multiplies that
so this becomes the maximum Scale, basically.
The Curve is going to make the star start small,
then get big and then get small again.
The effect is not looking too bad right now, but we can do a bit better.
One thing that I don't like is how the stars
can go pretty far up above the gem.
It would be nice if they couldn't go that far
and we can use a feature called Damping to do that.
It's going to make them slow down almost to a stop as they fade away.
For that, we expand the Damping category
and we crank up the Damping Value until the particles slow down enough
so they don't go that far up.
They start with that gravity pulling them up
and then slow down almost to a stop.
Right now, our effect is done.
We can open the Pickup Ghost after of course, saving the scene,
to see the sparkles appear there and on the Pickup Speed, as well.
I'm seeing one last thing that I want to change.
There are too many stars, right now.
So we go back to the Pickup scene with the particles to be selected
and go back all the way up to the top of the Inspector,
where we change the amount of particles.
Currently, eight means spawn eight stars per second.
We can lower that down to four, for example, or three.
You just need something a bit more reasonable.
Now if you save and go back to your Pickups,
you will see they have your automated sparkles
and you can test the game to see them in action.
Now, they really help to make the Pickup stand out.