Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion StarryExpanse/EverPresent/StrangerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,49 @@ void AStrangerController::AddHorizontalMouseScan(float amount) {
if (!IsCursorLockedToCenter) {
HorizontalMousePosition =
FMath::Clamp(HorizontalMousePosition + amount, 0.0f, 1.0f);

// check to see if we're within +tolerance for screen border
if (1 - HorizontalMousePosition < HorizontalMouseNudgeThreshold) {
// rotate the camera in accordance with how close the cursor is to the
// edge of the screen
this->AddYawInput(
(HorizontalMouseNudgeThreshold - (1 - HorizontalMousePosition)) *
HorizontalMouseNudgeMultiplier);
}

// check to see if we're within -tolerance for screen border
if (HorizontalMousePosition < HorizontalMouseNudgeThreshold) {
// rotate the camera in accordance with how close the cursor is to the
// edge of the screen
this->AddYawInput(
(-(HorizontalMouseNudgeThreshold - HorizontalMousePosition)) *
HorizontalMouseNudgeMultiplier);
}
}
}

void AStrangerController::AddVerticalMouseScan(float amount) {
if (!IsCursorLockedToCenter) {
VerticalMousePosition =
FMath::Clamp(VerticalMousePosition + amount, 0.0f, 1.0f);

// check to see if we're within +tolerance for screen border
if (1 - VerticalMousePosition < VerticalMouseNudgeThreshold) {
// rotate the camera in accordance with how close the cursor is to the
// edge of the screen
this->AddPitchInput(
(VerticalMouseNudgeThreshold - (1 - VerticalMousePosition)) *
VerticalMouseNudgeMultiplier);
}

// check to see if we're within -tolerance for screen border
if (VerticalMousePosition < VerticalMouseNudgeThreshold) {
// rotate the camera in accordance with how close the cursor is to the
// edge of the screen
this->AddPitchInput(
(-(VerticalMouseNudgeThreshold - VerticalMousePosition)) *
VerticalMouseNudgeMultiplier);
}
}
}

Expand All @@ -111,7 +147,6 @@ void AStrangerController::EnterCursorMode(bool fixed) {
VerticalMousePosition = 0.5;
} else {
this->IsCursorLockedToCenter = false;
this->IgnoreLookInput = 1;
}
}

Expand Down
14 changes: 14 additions & 0 deletions StarryExpanse/EverPresent/StrangerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ class STARRYEXPANSE_API AStrangerController : public APlayerController {
UPROPERTY()
float VerticalMousePosition = 0.5;

//how close (0.0 - 1.0) to the edge of the left/right of the screen you can get (in cursor mode) before the camera begins to pan
UPROPERTY(BlueprintReadWrite)
float HorizontalMouseNudgeThreshold = 0.25; //means that if the cursor is within 25% of the left/right of the screen, you'll start to pan

//how close (0.0 - 1.0) to the edge of the top/bottom of the screen you can get (in cursor mode) before the camera begins to pan
UPROPERTY(BlueprintReadWrite)
float VerticalMouseNudgeThreshold = 0.25; //means that if the cursor is within 25% of the top/bottom of the screen, you'll start to pan

UPROPERTY(BlueprintReadWrite)
float HorizontalMouseNudgeMultiplier = 4.0;

UPROPERTY(BlueprintReadWrite)
float VerticalMouseNudgeMultiplier = 4.0;

UFUNCTION()
void Cbk_MenuStateChanged();

Expand Down