Welcome back.
Now our loot is looking pretty sweet.
It's bobbing up and down.
It looks nice and smooth.
It's rotating and I really like how it looks, except for when they're spawned in and when they're spawned
in.
We just get this basic, you know, kind of just shows up.
Right.
And for that reason, I think I'd like something a little bit more special.
I'd like it to fly up and down.
Now, we could handle this in different ways.
You could enable physics, for example, and just let physics handle things.
I tend to like when it comes to stylized games like this, a little bit more of a stylized, more controlled
approach that doesn't have to do with physics.
I'd like to sort of use curves or timelines when making things fly up and hit the ground.
So for that reason, I'd like to control the vertical position of this based on a curve.
Now we have our BP pickup base, which can set the actor location based on our calculated location,
and we could use a curve to add to the calculated location.
We could use some kind of timeline that can take that calculated location and add a value to its z component,
for example.
And then every tick, we could just use that calculated location when setting the actor location.
So if we're running a timeline, then calculated location could be affected by it.
So right here I'd like to make a timeline right and begin play.
I'm going to add a timeline and call this pickup elevation.
Timeline and we'll go ahead and play it first thing and double click.
Give it a float.
Track and call this track elevation.
It's going to be normalized between 0 and 1.
And I'm just going to create a simple curve that starts off with zero at zero and goes to perhaps zero
at 0.75 or so, or maybe 0.8.
And our length of the curve will be 0.8 seconds.
And we'll have one in the middle at 0.4.
Right in the center, and this will be at a value of one.
And I'm going to zoom out and select all of these and make them auto so that we have this kind of curve.
And I'm going to take these endpoints here and angle them upward so that I have more of a parabolic
shape, more of a parabola.
And in fact I could go up to one second if I wanted some undershoot.
Let's go to 1.5 actually, and I could add a key here and add a key here.
And as long as these are auto curves.
We can shape this so that we have a bit of an undershoot.
So with this I have a 1.5 second timeline giving this elevation value and each update.
I'd like to take this elevation value and multiply it by a max elevation, some kind of apex.
I'm going to promote it to a variable and call this spawn apex.
And this can have its own value.
It could even be randomized too, but I'm just going to make it a constant with a value of 100.
And each time this update occurs we're going to add to our calculated location.
So we'll get calculated location.
We'll set calculated location, which we can't do unless it's blueprint read write.
So we'll have to change that.
Let's just do that real quick.
Back in our effect actor, we'll set calculated location.
We'll make it blueprint.
Read write.
While I'm at it, I'm just going to make calculated rotation blueprint read write as well and we'll
go ahead and launch again.
So we'll get this blueprint back open.
Back in BP pickup base.
And we need to set calculated location.
Now what are we setting it to.
We can't set it to itself plus this curve value.
We have to set it equal to actually its initial value.
Initial location, we'll have to use initial location.
Plus.
This value for the z component.
So I'm going to actually make a vector.
I'll make a vector from the float.
So I'm going to use make vector disconnecting that though.
And I'm going to use the initial locations x and y.
So I need to break this vector.
And use x and y, but for the Z, we're going to use what?
Well, we're going to use the initial location plus.
The curve value, of course.
Scaled by spawn.
Apex.
And that's going to be the calculated location.
So we're going to update this.
And what I want to do here is I don't want to start sinusoidal movement yet.
In fact I don't want to start sinusoidal movement or rotation until this curve is done.
So I'm going to move these over here and call them on finished.
And in the meantime we're setting calculated location I don't need that node there.
And.
When we spawn in.
Will be flying up and back down.
And then when that's done, we'll start rotating and bobbing up and down.
So let's try this out.
Actually, I need to load in through the menu.
Of course.
I could really use electrocute.
That ability is really nice for killing goblins.
Fast.
All right, so there we go.
So they fly up.
They come back down and it's flying up and down according to our curve instead of physics which I like
better.
And then once it hits the ground, then we get a nice bobbing sinusoidal movement because we started
sinusoidal movement.
I'm done with my BP crystals and potions as we're just working with pickup bass, so that's great.
That's looking nice.
Now another thing we can do is because these just spawn in and they just appear, right.
We could scale their size as well.
We can scale the mesh.
So first of all, to make this cleaner I'm going to collapse these.
I'm going to say collapse to a function and call this calculate elevation and make this a pure blueprint
pure function.
That's going to make things easier to see.
And we can even avoid crisscrossing.
Like this.
Now, in addition to this, we can have another curve value as we're running this curve.
We can also have another track float track called scale.
And this can be basically going from zero up to one.
And we can even have a little bit of some bobbing behavior too, especially when we get to about here
where the item flies up and comes back down.
What we can do is give it a little bit of a bobbing motion to the scale as well.
So here's what I'm going to do.
I'm going to make a key on time zero at zero and very rapidly go up to one.
So I'm going to have another key here at time.
Let's make it 0.1 and we'll have it go up to let's go up to 1.2.
And I'll have another key that Undershoots will go down to about 0.82.
And another key that overshoots slightly.
And then a key at one.
So this will have a value of one.
Now of course I'm going to want these to be auto, but I'm going to hold off on making them auto for
now.
I'm going to come all the way over to the part where they hit the ground and make them bob a little
bit more.
So I'm going to put a key here and a key here, and we'll undershoot, overshoot and then back to one.
So now I'm going to make them all auto curves and shape them.
I want this first one going straight.
Going up like this will overshoot a little.
I'll make this one a little more straight.
And if I want to rotate this on one side but not the other, I can actually right click and make this
broken so I can use break, and then I can use one side at a time by selecting that.
And that's what I'd like for this case here.
I'd like to go up and down again.
So now we have this curve.
And we can scale our meshes, scale our actors, scale using this value.
So what I can do is I can simply call set scale 3D.
We'll use set actor scale 3D.
And for this scale 3D, I can right click.
And split the struct pin and we can use this scale value.
I'm going to reroute it.
And reroute it, and then plug in the same value for all three of these.
And that's going to scale according to the curve.
Let's see how that looks.
Now, I'd like to see this in slow motion.
So I'm going to lure a couple of enemies over, and then I'm going to hit Tilda.
Slow mo point five.
Now we're going half the time.
There we go.
Look at that.
They bob and they bob.
When they hit the ground, they don't really hit the ground, but they bob again when they fall down.
Let's use like slo mo point one.
We'll go to about 10%.
Of the time.
So, Tilda, slo mo point one.
Now we're 10% and it's going to take a while to.
Kill these things.
But that's okay.
It'll be worth it.
Oh.
We're a little close, so.
Let's go.
Almost there.
We'll kill this one this time.
Boom.
Okay, now we see the potions coming up.
See how they're bobbing?
Bigger?
Smaller.
They're kind of like they look a little bit like they're sort of rubbery.
And when they hit the lowest point, then they bob again, and then they start rotating, doing their
bobbing sinusoidal motion.
I think that looks great.
So that's a little bit more of a stylized way to handle spawning these things.
And I think that looks really nice.
It gives for a better effect than just spawning them in, making them appear, you know.
Now the last thing that we can give to these looks like I hit myself.
I could target myself.
The last thing for these pickups that I'd like to do is sounds.
And I have some sounds for spawning in these potions.
And really, I don't have sounds for the crystals, but we can just reuse the same sounds for the crystals
as for the potions.
And so I think that'll give us one last final touch for spawning these items.
So we'll do that next.
Great job and I'll see you soon.