Implement camera perspective toggle

This commit is contained in:
2026-05-15 10:44:02 -07:00
parent c5e795ef26
commit cd8de0f906
8 changed files with 206 additions and 4 deletions
+26 -1
View File
@@ -73,10 +73,26 @@ protected:
UPROPERTY(EditAnywhere, Category="Input")
UInputAction* InteractAction;
/** Toggle between third-person and first-person camera views. */
UPROPERTY(EditAnywhere, Category="Input")
UInputAction* ToggleCameraAction;
/** How far the player can interact with MVP objects. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Agrarian|Interaction", meta = (ClampMin = "100"))
float InteractionDistance = 450.0f;
/** Third-person spring arm distance used when returning from first person. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Agrarian|Camera", meta = (ClampMin = "0"))
float ThirdPersonCameraDistance = 400.0f;
/** Local first-person camera offset relative to the capsule root. */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Agrarian|Camera")
FVector FirstPersonCameraOffset = FVector(0.0f, 0.0f, 72.0f);
/** True when this local character is using the optional first-person view. */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Agrarian|Camera", meta = (AllowPrivateAccess = "true"))
bool bFirstPersonCamera = false;
public:
/** Constructor */
@@ -98,6 +114,12 @@ protected:
/** Called for interaction input */
void Interact();
/** Called for camera perspective toggle input */
void ToggleCameraPerspective();
/** Applies local camera presentation state. */
void SetFirstPersonCamera(bool bEnableFirstPerson);
public:
/** Handles move inputs from either controls or UI interfaces */
@@ -120,6 +142,10 @@ public:
UFUNCTION(BlueprintCallable, Category="Agrarian|Interaction")
virtual void TryInteract();
/** Returns true when this local character is using first-person camera presentation. */
UFUNCTION(BlueprintPure, Category="Agrarian|Camera")
bool IsFirstPersonCamera() const { return bFirstPersonCamera; }
/** Server-authoritative interaction entry point. */
UFUNCTION(Server, Reliable)
void ServerInteract(AActor* TargetActor);
@@ -144,4 +170,3 @@ public:
/** Returns BuildingPlacementComponent subobject **/
FORCEINLINE UAgrarianBuildingPlacementComponent* GetBuildingPlacementComponent() const { return BuildingPlacementComponent; }
};