OpenDoor Deigned Component

Hi, so this is my OpenDoor() class header file.

I found that you can add meta data to the UPROPERTY macro to clamp the min and max values permitted within the UE editor by using ‘Meta = (ClampMin = “0.0”, ClampMax = “360.0”)’.

Also, the comments on the UPROPERTY variables act as tooltips for the exposed properties in the UE editor.

OpenDoor.h

...
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class BUILDING_ESCAPE_API UOpenDoor : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UOpenDoor();

protected:
	// Called when the game starts
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
	void Open(float DeltaTime, float FinalYaw);
	void Close(float DeltaTime, float StartYaw);

public:
	// Yaw angle for the open door
	UPROPERTY(EditAnywhere, Meta = (ClampMin = "0.0", ClampMax = "360.0"), BlueprintReadWrite, Category = Properties)
	float OpenYaw = 90.0f; 

	// Door's delay before closing (secs)
	UPROPERTY(EditAnywhere, Meta = (ClampMin = "0.0"), BlueprintReadWrite, Category = Properties)
	float CloseDelay = 2.0f;

	// Open Door interpolation speed
	UPROPERTY(EditAnywhere, Meta = (ClampMin = "0.0"), BlueprintReadWrite, Category = Properties)
	float OpenRate = 2.0f;  

	// Close Door interpolation speed
	UPROPERTY(EditAnywhere, Meta = (ClampMin = "0.0"), BlueprintReadWrite, Category = Properties)
	float CloseRate = 1.0f;

	// Door's open trigger
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Properties)
	ATriggerVolume* PressurePlate = nullptr;

	AActor* ActorThatOpens = nullptr; // Ptr to the triggering actor

private:
	float TargetYaw;  // The doors yaw angle when opened
	float InitalYaw;  // The doors initial yaw angle when closed
	float LastOpened = 0.0f;  // Time when the door was opened (secs)
};

Privacy & Terms