Using a Timeline in Blueprints to Make a Moving Platform

In this example we’re making a simple platform that, when the player walks on it, goes up, holds for a short moment and moves back down.

1

Here is the Actor Blueprint setup in the Viewport. I added SM_AssetPlatform from the starter content but you can use anything. First I made sure that I had some collision on it. Then, as a parent of the platform, I added a small box collision volume on top. When the user overlaps with that volume, the Blueprint script below is activated.

2

I am using a Timeline node. A timeline will run for however long you wish changing a variable during that time. (You can set up your timeline by clicking on it, see below). Here I am taking the original position of the platform as it’s placed in the level and storing it in a vector variable I named ‘originalPos’. Then I am breaking up the three floats from that vector as we only want to move the Z (up and down) position. Using the timeline I am then adding 300 units to the Z position and then putting it back down to 0. I attach that to a SetActorLocation node from the update on the Timeline.

3

Here you can see what the timeline editor looks like. It opens up in a new tab from my blueprint. I added a float variable by clicking on the f+ icon in the upper left (vectors, events and colors are some of the other things you can add to a timeline). You can click on the red line to make new keyframes in the timeline to change your variable around. You can also right click on the frames to get different interpolation. Here I am using “User” so I can get a smoother graph so the animation isn’t too jerky.

4