How to make a basic elevator in UE4

A brief overview about how to get a button to communicate with an elevator in Unreal Engine 4.

 

The above exchange between the button and the elevator is made up of 2 blueprint classes. One button blueprint (BP_elevatorButton) and one elevator blueprint (BP_elevatorTest).

So I want to be able to tell my BP_elevatorButton to execute code in BP_elevatorTest when pressed.

One of the basic methods of communicating between class blueprints is a function called “Get all Actors of Class“. Get all Actors of Class essentially tells the engine to run through all of the actors in your scene that match the class that you specify in the node (in my case I specified BP_elevatorTest) and then add them into an array.  In order to specify the specific BP_elevatorButton instance I want to run code on, I have to specify the array ID with a “GET“. Because there is only one BP_elevatorTest in my scene, I can just leave my GET command at 0, as 0 is the first entry in the array.

With that set up, I can just make a custom event in my BP_elevatorTest and execute any code I want from there.

 

Here you can see the BP_elevator button blueprint. I’m receiving the raytrace from the player, animating the button motion, and then casting to my elevator and running the Elevator UP event.

Here’s the Elevator UP function which is a basic “Move Component To” function.

Leave a Reply

Your email address will not be published. Required fields are marked *