How to Use Timelines in C++

Hey guys, I’m working on my first project using UE4 and am having a bit of difficulty in understanding how to properly use Timelines in C++. Up until now I have been using the Construction graph for my game object blueprints (Which derive from custom c++ classes) to get reference to the blueprint components. I thought that I could use a similar approach (setting up a timeline in blueprints and defining a UTimelineComponent in code for reference), however it appears that this does not work.

I have found this page:
https://answers.unrealengine.com/questions/115830/why-is-timeline-bindufunction-only-called-once.html
which (I think) shows a working piece of code however my basic understanding of c++, and the general way that timelines function within the engine are making this hard for me to understand.

For my purposes I am trying to make an animation for a button that when pressed should push down, and then spring back some time later.

my understanding is as follows:
a UCurveVector object is used to hold the curve information, defining an output vector for each point in time.

a FTimeline object is responsible for ‘stepping’ through the curve and outputting the FVector that the curve defines at each point.

With this output we can do things like move Actor components (i.e define behavior)

From the example in the link above it appears that FTimeline::AddInterpVector() should be used to define the curve, however the second argument which required a FOnTimelineVector I am finding very confusing.
In the example it appears as though this is some kind of function that is bound to some kind of handler function which can receive the vector information from each tick, but this seems rather redundant to me (Why doesn’t the AddInterpVector() function just want reference to some function directly?)

Additionally the syntax for the BindUFunction method, which from what I can tell connects the handler function to the FOnTimeLineVector, is causing confusion. What is an FName and why do we need to refer to our ‘handler’ function in this way?

I have tried to find answers to these questions in the UE4 documentation but am finding some of the description very vauge.

eg UTimelineComponent::AddInterpVector | Unreal Engine Documentation

and UTimelineComponent::AddInterpVector | Unreal Engine Documentation

Any help in getting me to understand these concepts will be appreciated

Matt have you found anything? I’m searching as well but no luck

Unfortunately no. I think that I ended up making a custom blueprint event that fired the timeline in blueprints. I have since lost this project because of a hard drive failure :frowning:

Hello, check out this post. It will give you a head start so you can understand the general concept of using timelines with C++.

-Orfeas

This was very useful for myself: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums