Create and use your Prefab Properties Objects
About
In Make your first prefab actor we created a simple prefab door actor which opens and closes in 1 second.
We are going to make the open and close duration customisable per spawned door prefab actor.
Step 1 - Create your Prefab Properties Object class
In the Content Browser create a new blueprint inheriting from PSSingleActorPrefabProperties
and name it BP_PrefabProperties_Door
.

Inside create 2 float variables called OpenDuration
and CloseDuration
. Be sure to enable Instance Editable to true
(you can also set Units to Seconds
). You can also set a Default Value and a Category.

Step 2 - Use the Prefab Properties Object class in the prefab actor
Inside the door prefab actor we previously made add a Single Prefab Source Component.
Then click on the component and implement the On Properties Set delegate, from the given event node use the Get Prefab Properties Object of Class node with BP_PrefabProperties_Door
and save the result is a variable.

Still inside your door prefab, add a new function called UpdateDoorAnimationSpeed
and call it after the Open
and Close
events like so:

Inside UpdateDoorAnimationSpeed
add the following code (this will change the timeline play speed to match the open/close duration):

Step 3 - Use the Prefab Properties Object class in the Prefab Reference Component
Inside the Prefab Reference Component that is using the door prefab actor add the BP_PrefabProperties_Door
prefab properties object entry and set the values as you like.

Final result
Now anywhere you use your prefab door actor you can control the open and close durations remotely from the Prefab Reference Component that is spawning it.
Last updated