Opening Doors with a Level Sequence in Unreal Engine

- by

In a previous article I’ve explained how to trigger an animation with a timeline node. I thought it might be nice to see a different approach to the same problem, so in this article I’ll show you how to do this with a Level Sequence. The concept allows more flexibility on complex animations. In principle we’ll have to

  • create a Level Sequence
  • drag the objects we want animate onto it
  • animate them
  • trigger the sequence with a collision object

Let’s take a look at this step by step in Unreal Engine 5.1.

Creating the Level Sequence

We can create a Level Sequence in two different ways, either from the top menu mini icon, or by right clicking in the Content Browser. Pick what works best for you.

from the Top Menu
or the Content Browser

Bizarrely, it’s classed as a Cinematic. It’s totally not what we’re using it for, but them’s the rules. Name it something descriptive (like Door Sequence), then open it. A new tab will pop up next to your content browser.

Select the object you’d like to animate in your viewport, then find it in the World Outliner. In my case, I have two doors I’d like to rotate inwards. I’ll drag each of them onto the empty sequencer track to create a reference. This will allow me to set keyframes on any of the object’s properties.

I’ll set the duration of my sequence to 2 seconds, then select each door and animate them to be closed at the beginning, and open at the end. When I’m happy with the result, I’ll drag my sequence into the level so that the Level Blueprint can grab a reference to it in a moment. This will instantiate the class without us having to do it in code.

With the sequence selected in the level, let’s enable Pause at End in the Details Panel. This will prevent from our sequence from snapping back to the beginning position should it get re-triggered.

Triggering the Sequence

Let’s drag a Box Collision into the viewport and scale it up so that the player can walk into it conveniently. I’ll make mine large enough so that it works from both sides. I’ll select it in the viewport, then open up my Level Blueprint and righ-click in the Event Graph to create the On Actor Begin Overlap event node. Because my box collision is selected, Unreal Engine knows that I might want to do something with its properties, that’s why they’re showing up here. Super convenient!

I’m going to have my doors open (i.e. play my sequence) when the player steps in, and I’d like to close the doors (i.e. play my sequence backwards) when the player steps out of the collision volume. For the latter part, I’ll use the On Actor End Overlap node.

With both nodes in place, I’ll select the sequence in my viewport and switch back to the Level Blueprint, grab a reference to it, then drag off and search for something that contains “play”. This should bring up the Play and Play Reverse nodes, both off which are functions on the Sequence Player (which in turn is part of my level sequence object). Both nodes will start playing our animation, which then opens my doors.

This is a really neat way to kick off all kinds of animated objects in the scene, no matter if the player controls the character, or if an animated object collides with another one. Have fun with it!



If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

Leave a Comment