- Create a new C++ class derived from the StaticMeshActor class using the editor wizard; call it SlidingDoor.
- Add the following text that's in bold to the new class:
class CHAPTER_09_API ASlidingDoor : public AStaticMeshActor{ GENERATED_BODY() public: // Sets default values for this actor's properties ASlidingDoor();protected: // Called when the game starts or when spawned virtual void BeginPlay() override;public: // Called every frame virtual void Tick(float DeltaTime) override; UFUNCTION(BlueprintCallable, Category = Door) void Open(); UPROPERTY() bool IsOpen; UPROPERTY() FVector TargetLocation;};
- Create the class implementation by adding the following text in bold to the .cpp file:
#include "SlidingDoor.h"#include "ConstructorHelpers.h" ...