Don't write clever code

This commit is contained in:
2022-06-05 22:44:34 +02:00
parent aa02fb8093
commit 28a226e35d
3 changed files with 71 additions and 42 deletions
+17 -22
View File
@@ -54,16 +54,11 @@ void AAdventureCameraPawn::GetTheDamnViewport()
void AAdventureCameraPawn::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// quick fix for edgescrolling after viewport resizing.
//
//TickIncrement++;
//if (TickIncrement >= 60) {
// TickIncrement = 0;
// ViewSize = Viewport->Viewport->GetSizeXY();
//}
if (IsValid(FollowPawn)) { if (FollowPawn->bIsMoving) { FollowAdvPawn(DeltaTime); } }
if (IsValid(FollowPawn)) {
if (FollowPawn->bIsMoving) {
FollowAdvPawn(DeltaTime);
}
}
}
// Called to bind functionality to input
@@ -101,18 +96,18 @@ void AAdventureCameraPawn::EdgeScrollSide(float AxisValue)
float mousePosY = mouseY / ViewSize.Y;
float VertAccelleration = GetInputAxisValue("Mouse Y") * (ScrollAccelleration * .75);
if (mousePosX <= ESASize) // if in LEFT area
if (mousePosX <= ESASize) // in LEFT area
{
////// Scroll LEFT
float SpeedX = (mousePosX * ESAMinBoundSlope + ESAMinBoundIntercept) * BaseScrollSpeed;
AddActorLocalOffset(FVector(-SpeedX, 0, 0));
if (mousePosY > .005) // if not touching TOP EDGE
if (mousePosY > .005) // not touching TOP EDGE
{
AddActorLocalOffset(FVector(0, -VertAccelleration, 0));
}
if (AxisValue < .0 && mousePosX <= .005) // if mouse moving LEFT and touching EDGE
if (AxisValue < .0 && mousePosX <= .005) // mouse moving LEFT && touching EDGE
{
////// Add LEFT accelleration
SpeedX = AxisValue * ScrollAccelleration;
@@ -120,18 +115,18 @@ void AAdventureCameraPawn::EdgeScrollSide(float AxisValue)
}
}
if (mousePosX >= 1-ESASize) // if in RIGHT area
if (mousePosX >= 1-ESASize) // in RIGHT area
{
////// Scroll RIGHT
float SpeedX = (mousePosX * ESAMaxBoundSlope + ESAMaxBoundIntercept) * BaseScrollSpeed;
AddActorLocalOffset(FVector(SpeedX, 0, 0));
if (mousePosY < .995) // if not touching BOT EDGE
if (mousePosY < .995) // not touching BOT EDGE
{
AddActorLocalOffset(FVector(0, -VertAccelleration, 0));
}
if (AxisValue > .0 && mousePosX >= .995) // if mouse moving RIGHT and touching EDGE
if (AxisValue > .0 && mousePosX >= .995) // mouse moving RIGHT && touching EDGE
{
////// Add RIGHT accelleration
SpeedX = AxisValue * ScrollAccelleration;
@@ -149,18 +144,18 @@ void AAdventureCameraPawn::EdgeScrollVert(float AxisValue)
float mousePosX = mouseX / ViewSize.X;
float SideAccelleration = GetInputAxisValue("Mouse X") * (ScrollAccelleration * .75);
if (mousePosY <= ESASize) // if in TOP area
if (mousePosY <= ESASize) // in TOP area
{
////// Scroll TOP
float SpeedY = (mousePosY * ESAMinBoundSlope + ESAMinBoundIntercept) * BaseScrollSpeed;
AddActorLocalOffset(FVector(0, -SpeedY, 0));
if (mousePosX > .005) // if not touching EDGE
if (mousePosX > .005) // not touching EDGE
{
AddActorLocalOffset(FVector(SideAccelleration, 0, 0));
}
if (AxisValue > .0 && mousePosY <= .005) // if mouse moving TOP and touching EDGE
if (AxisValue > .0 && mousePosY <= .005) // mouse moving TOP && touching EDGE
{
////// Add TOP accelleration
SpeedY = AxisValue * ScrollAccelleration;
@@ -168,18 +163,18 @@ void AAdventureCameraPawn::EdgeScrollVert(float AxisValue)
}
}
if (mousePosY >= 1-ESASize) // if in BOTTOM area
if (mousePosY >= 1-ESASize) // in BOTTOM area
{
////// Scroll BOTTOM
float SpeedY = (mousePosY * ESAMaxBoundSlope + ESAMaxBoundIntercept) * BaseScrollSpeed;
AddActorLocalOffset(FVector(0, SpeedY, 0));
if (mousePosX < .995) // if not touching BOT EDGE
if (mousePosX < .995) // not touching BOT EDGE
{
AddActorLocalOffset(FVector(SideAccelleration, 0, 0));
}
if (AxisValue < .0 && mousePosY >= .995) // if mouse moving BOTTOM and touching EDGE
if (AxisValue < .0 && mousePosY >= .995) // mouse moving BOTTOM && touching EDGE
{
////// add BOTTOM accelleration
SpeedY = AxisValue * ScrollAccelleration;