You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.5 KiB
41 lines
1.5 KiB
// Copyright Voulz 2021-2025. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Components/ActorComponent.h"
|
|
#include "FaceCameraComponent.generated.h"
|
|
|
|
|
|
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
|
class ARCHVISTOOLS_API UFaceCameraComponent : public UActorComponent
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
// Sets default values for this component's properties
|
|
UFaceCameraComponent();
|
|
|
|
/** If set to true, the Component will force the Actor to Face the Camera on Tick */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Face Camera")
|
|
bool bFaceCameraActive = true;
|
|
|
|
/** If set to true, the Component will also rotate its Roll to align to the camera, otherwise it will stay vertical */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Face Camera")
|
|
bool bAllowRoll = false;
|
|
|
|
/** The added rotation required for the right part of the Actor to face the Camera. The default will align the Y Axis of the Actor to the Camera */
|
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Face Camera")
|
|
FRotator AddedRotation = FRotator(0.f, 90.f, 0.f);
|
|
|
|
/** The function called to make the Actor face the Camera */
|
|
UFUNCTION(BlueprintCallable, Category="Face Camera")
|
|
void MakeActorFaceCamera();
|
|
|
|
// Called every frame
|
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
|
|
|
/** Gets the location of the Camera in the editor, it should still work even in play mode */
|
|
UFUNCTION(BlueprintPure, Category="Face Camera")
|
|
FVector GetEditorCameraLocation() const;
|
|
};
|
|
|