Actor move from A to B with lerp but want to add a curve

Create a spline with 3 points. Use the timeline + lerp to get interpolated spline location. I think it’s called Get Location at Time.


Alternatively, you could experiment with a homing projectile, too. You might get good results but somewhat less control, though. Depends on what you’re after.

Hello!

I have a blueprint with an actor moving from A to B with a lerp.
But I want to have it as a curve instead of a straight line as it is now.
So the effect I want is this: https://d1u1mce87gyfbn.cloudfront.net/media/screenshot/mercy-screenshot-002.jpg

Any ideas on how I would go about doing this?
Thanks!

Hello!
With a Spline I wont be able to move the A and B points without tweaking the Spline right?

That is what I want to avoid :slight_smile:

You will, this can be automated.

You set Spline point A to start location and spline point C to the end location. You can set B depending on where the A and C are.

(A + C) / 2 is where you place spline point B; add local offset in the desired direction, and that’s your curve. The interpolation is automatic but you can tweak if you want.

Once you have this working, the only thing to worry about is to manipulate the locations of A & C points.

Here’s what I mean:

Image from Gyazo

Use the Curve Offset attribute (I hardcoded it here) to control the curve. One you have it working, look into spline tangents to control the shape of the curve with more fidelity.

Awesome thanks!!!

Just one more question, I cant seem to find the same “Update Spline” with Curve start and Curve end as you.
Nor the Update Spline Event?

Thanks!
Daniel

It’s a custom event you make yourself. Search for custom event and give it inputs, it’s a way to create a bit of reusable script.

Awesome! Had no idea you could do that!
Thanks so much!

I got an e-mail notification with your comment, but for some reason I can’t see it here. Probably due to weekend moderation being on the slower side:

Anyhow, you said:

Would you know why when I pipe in a
Get World Location on the Update
spline so I can move them around
dynamically, the locations are moved
to a totally different place then the
ones I pipe in?

Yeah, sure. The stuff I posted is just an example usage rather than a ready-to-go solution. Currently it all operates in local space, that’s apart from the debug dots which operate in world space.

It depends on the data fed into the Custom Event. Set Set Spline Points to World rather than Local. This will make the spline move in the world space. Also, when you make any object follow it, (like the sphere, here) do not use Relative Location but World Location instead.

I’m not sure what you need it for precisely; as in, how it’s going to work and what moves what. So it’s kind of hard to advise directly.

It’s all good i figured it out, thanks! :smiley:

I tried to follow your Blueprint, but this is as close as I could get:

Why does my “Update Spline” component look different than yours?

Why does my “Update Spline” component
look different than yours?

On Begin Play calls a function belonging to the spline component. Call the the Custom Event that was created in the graph instead - here, it was (unfortunately!) also named UpdateSpline and this is where the confusion is coming from. My bad. Perhaps rename the custom event to something more meaningful to avoid similar names and call that.

Also, your timeline will not play. When you open it (by double clicking, do ensure that Autoplay and Loop are ticked:

Do tell if you got it to work.

I’m aware that there are two different functions with nearly identical names. That isn’t the question being asked. What I’m asking is why does your built-in, non-custom “Update Spline” function look different from my built-in, non-custom “Update Spline” function?

Here’s an image that isolates your and mine and puts them side-by-side for comparison:

Is this just because you were using an older version of UE4 when you made your graph, and Epic has since changed the way their built-in “Update Spline” function works, or is there something else I’m missing here?

Also, on the “Timeline_0” function, what type of track should I add? A float track, a vector track, or an event track? Your original graph showed a “New_Track_0” as output from the “Timeline_0” function, but you didn’t specify which type of track should be created.

What I’m asking is why does your
built-in, non-custom “Update Spline”
function look different from my
built-in, non-custom “Update Spline”
function?

Mine is not built-in, and it’s not a function - do note the icons on the nodes (and their targets), it’s a custom event call. I made a custom event (below) and I’m calling it (above):


Also, on the “Timeline_0” function,
what type of track should I add? A
float track, a vector track, or an
event track? Your original graph
showed a “New_Track_0” as output from
the “Timeline_0” function, but you
didn’t specify which type of track
should be created.

A float track. The easiest way to identify it is via the colour of the wires / variable nodes:

311945-nodes.jpg

Mine is not built-in, and it’s not a function - do note the icons on the nodes (and their targets), it’s a custom event call. I made a custom event (below) and I’m calling it (above).

Oh, okay. I get it now. I got confused because the event call had a blue header instead of a red one.

Anyway, I got it working. I had to create an animation curve for the Float track (your instructions above omitted this step), and I also had to put a checkmark in box next to the option that says “Use Last Keyframe?” because otherwise it would just do the animation once and then stop, even with “Loop” checked.

Thanks for your help! ^_^/

also had to put a checkmark in box
next to the option that says “Use Last
Keyframe?” because otherwise it would
just do the animation once and then
stop, even with “Loop” checked.

That’s because the TL length is left at the default 5s while your last key is at 1s mark. You’d need to wait 5s for it to restart and loop.

Here’s a bit more about timelines:

https://docs.unrealengine.com/en-US/Engine/Blueprints/UserGuide/Timelines/index.html