Make your first prefab actor

About

In this tutorial we will create a door prefab actor which will open when the player is near and close when the player goes away.

Step 1 - Create your prefab actor

1.1 Create the actor blueprint

Create a new blueprint actor (in this example it will be named ABP_House_AutoDoor).

Add your door meshes and a Box Collision (you can ignore the Prefab Source Component).

To get the door meshes you need to import the Starter Content.

1.2 Add your logic

Add a new boolean var called IsClosed, set the default value to true.

Add the following 2 custom events and code:

The timeline is a Float Track of length 1 and that starts at (0,0) and finishes at (1,1).

Next, add these two overlap events (from the box collision component):

In this demo project the player character class is BP_ThirdPersonCharacter, you can replace this by whatever class you are using or any other method to identify the player.

Now you should have a working door which opens and closes in 1 second.

Step 2 - Use your prefab actor in a Prefab Reference Component

Inside another blueprint actor class add a Prefab Reference Component, select the Single Prefab Spawn Class Getter class and select your prefab door class.

Final result

If you place your actor containing the Prefab Reference Component in the level and press play, the ABP_House_AutoDoor blueprint will be automatically spawned.

See Create and use your Prefab Properties Objects for the next steps of using Prefab Properties Objects to control the door open and close durations.

Last updated