In this post I'm going to show you how to create latent Blueprint nodes that…
Consuming Timelines using C++
In this tutorial I’m going to show you how you can consume and handle timelines using C++. With Timelines you can create simple time-based animations such as opening doors, altering lights or performing other time-centric manipulations to Actors within a scene. Each timeline needs at least one curve in order to run. The curve describes the transition of a value (or values – depending on the curve you provide) according to time. In this post I’m going to create a simple float curve. A float curve contains float values which interpolate between a given time range. Unreal Engine 4 provides three types of curves:
- CurveLinearColor and
Once you get the hang of the workflow, you will be able to extend the functionality of curvefloat to the other two curves as well!
Before we get started, here is the end result of this post:
Preparing our project
In order to consume a curvefloat we need the following things:
- A curvefloat
- A timeline which contains the curvefloat
- A function which handles the progress of the timeline (in this post, I will create this function inside the Actor I’m going to create in a bit)
Creating a Float curve
Before we type any code, we should create our curve first. Right click somewhere in the empty space of your content browser and select the Float Curve from the Miscellaneous menu as seen below:
When you’re done with that, create the following curve (to add points in your curve hold “Shift” and click somewhere in the curve space):
The X axis represents the time and the Y axis represents the values that our function will take as parameters. Once you’re done, save your curve.
Creating a floating Actor
Add a new C++ class which inherits from the Actor class and name it FloatingActor. Once your header file loads, type in the following code:
Switch to your source file, and type in the following code:
Build your code and create a Blueprint based on the Actor class we created. Place it on your level and copy the following values*:
That’s it! If you simulate your level you should have a result similar to the video in the beginning of the post!
*In case you can’t find the cone static mesh make sure to enable the following option:
This Post Has 15 Comments
Hello! I have been trying to get this work but unsuccessfull. Unreal Engine doesn’t recognize the FTimeline class correctly. If i write FTimeline Mytimeline;
Unreal engine starts to say “Unknown identifier”. Game doesn’t compile and i don’t have access to any methods of the Mytimeline. I try to update 4.13 version to date and even tried with 4.14 version. Same thing happen. Could you look up to it?
Hello, I think that from 4.12 version and later on you have to include the TimelineComponent.h in your header files.
You are correct. It really needed the header. Thanks for all these tutorials.
Thank you for your support!
Great tutorial again Orfeas.
I have one question. How would I modify this if I wanted to be able to attach the floating functionality to another existing actor?
Would I make this into an interface class then use multiple inheritance and overrides in my other class?
Also Line 24 of the c++ file was a little confusing but I think I understood it.
You can embed that functionality in a component and then attach the component in the desired actor. By line 24 I’m assuming you’re refering to ProgressFunction.BindUFunction(this, FName(“HandleProgress”)). This line tells the compiler that when the ProgressFunction executes, it will call the HandleProgress function.
Ok I see, thanks
How can I bind function with parameter to timeline Update or Finished nodes
Check out the source code in this link: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Engine/Classes/Components/TimelineComponent.h#L244
Thank you for posting this.
Hello, any clue of how i use a Timeline with Event Track in C++?
I haven’t had the time to search this so I’m afraid I can’t help you with that at the moment.
hello, I have a question what is the difference between FTimeline and FtimelineComponent ?
thanks a lot
Hello.. thanks for this tutorial…
You forgot to assign the static mesh component to the actor’s root component.