Unreal Engine 4.x Scripting with C++ Cookbook - Second Edition
by John P. Doran, William Sherif, Stephen Whittle
How it works...
Within the declaration of the door, we create a new function for opening the door, a Boolean to track whether the door has been told to open, and a vector allowing us to precompute the target location of the door.
We also override the Tick actor function so that we can perform some behavior on every frame.
Within the constructor, we load in the cube mesh and scale it to represent our door.
We also set IsOpen to a known good value of false and enable actor ticking by using bCanEverTick and bStartWithTickEnabled.
These two Booleans control whether ticking can be enabled for this actor and if ticking starts in an enabled state, respectively.
Inside the Open function, we calculate the target location that's relative to the door's ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access