Camera now following Pawn
This commit is contained in:
+7
-12
@@ -54,6 +54,7 @@ void AAdventureCameraPawn::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (IsValid(FollowPawn)) { if (FollowPawn->bIsMoving) { FollowAdvPawn(DeltaTime); } }
|
||||
}
|
||||
|
||||
// Called to bind functionality to input
|
||||
@@ -69,18 +70,19 @@ void AAdventureCameraPawn::SetupPlayerInputComponent(UInputComponent* PlayerInpu
|
||||
PlayerInputComponent->BindAxis("Move WS", this, &AAdventureCameraPawn::ScrollVert);
|
||||
}
|
||||
}
|
||||
|
||||
void AAdventureCameraPawn::ScrollSide(float AxisValue)
|
||||
{
|
||||
float DeltaLoc = AxisValue * BaseScrollSpeed * 3;
|
||||
AddActorLocalOffset(FVector(DeltaLoc, 0, 0));
|
||||
}
|
||||
|
||||
void AAdventureCameraPawn::ScrollVert(float AxisValue)
|
||||
{
|
||||
float DeltaLoc = AxisValue * BaseScrollSpeed * -3;
|
||||
AddActorLocalOffset(FVector(0, DeltaLoc, 0));
|
||||
}
|
||||
|
||||
|
||||
void AAdventureCameraPawn::EdgeScrollSide(float AxisValue)
|
||||
{
|
||||
float mouseX;
|
||||
@@ -178,16 +180,9 @@ void AAdventureCameraPawn::EdgeScrollVert(float AxisValue)
|
||||
}
|
||||
}
|
||||
|
||||
void AAdventureCameraPawn::FollowAdvPawn()
|
||||
void AAdventureCameraPawn::FollowAdvPawn(float DeltaSeconds)
|
||||
{
|
||||
UE_LOG(LogTemp, Warning, TEXT("following..."));
|
||||
|
||||
AdvPawnLocationCurrent = FollowPawn->GetActorLocation();
|
||||
AdvPawnLocationDelta = AdvPawnLocationCurrent - AdvPawnLocationPrevious;
|
||||
|
||||
UE_LOG(LogTemp, Warning, TEXT("%s"), *AdvPawnLocationDelta.ToString());
|
||||
|
||||
AddActorLocalOffset(AdvPawnLocationDelta);
|
||||
|
||||
AdvPawnLocationPrevious = AdvPawnLocationCurrent;
|
||||
bool MapPawnInViewX = (FMath::Abs(FollowPawn->GetActorTransform().GetLocation().X - this->GetActorLocation().X)) < ViewSize.X;
|
||||
bool MapPawnInViewY = (FMath::Abs(FollowPawn->GetActorTransform().GetLocation().Y - this->GetActorLocation().Y)) < ViewSize.Y;
|
||||
if (MapPawnInViewX && MapPawnInViewY) { AddActorLocalOffset(FollowPawn->GetVelocity() * DeltaSeconds); }
|
||||
}
|
||||
Reference in New Issue
Block a user