Gate Setting Actor Location Behind Bounds Check
This commit is contained in:
parent
c1e4387adb
commit
cb0230d24f
@ -61,7 +61,7 @@ void APlayerCharacter::Tick(float DeltaTime)
|
|||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
auto PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
|
APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
|
||||||
|
|
||||||
FVector TopLeft, TopLeftDir;
|
FVector TopLeft, TopLeftDir;
|
||||||
FVector BottomRight, BottomRightDir;
|
FVector BottomRight, BottomRightDir;
|
||||||
@ -72,11 +72,14 @@ void APlayerCharacter::Tick(float DeltaTime)
|
|||||||
PlayerController->DeprojectScreenPositionToWorld(0, 0, TopLeft, TopLeftDir);
|
PlayerController->DeprojectScreenPositionToWorld(0, 0, TopLeft, TopLeftDir);
|
||||||
PlayerController->DeprojectScreenPositionToWorld(ViewportSize.X, ViewportSize.Y, BottomRight, BottomRightDir);
|
PlayerController->DeprojectScreenPositionToWorld(ViewportSize.X, ViewportSize.Y, BottomRight, BottomRightDir);
|
||||||
|
|
||||||
auto location = GetActorLocation();
|
FVector Location = GetActorLocation();
|
||||||
location.X = FMath::Clamp(location.X, BottomRight.X, TopLeft.X);
|
if (Location.X < BottomRight.X || Location.X > TopLeft.X || Location.Y > BottomRight.Y || Location.Y < TopLeft.Y)
|
||||||
location.Y = FMath::Clamp(location.Y, TopLeft.Y, BottomRight.Y);
|
{
|
||||||
|
Location.X = FMath::Clamp(Location.X, BottomRight.X, TopLeft.X);
|
||||||
|
Location.Y = FMath::Clamp(Location.Y, TopLeft.Y, BottomRight.Y);
|
||||||
|
|
||||||
SetActorLocation(location);
|
SetActorLocation(Location);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UEXPComponent* APlayerCharacter::GetEXPComponent()
|
UEXPComponent* APlayerCharacter::GetEXPComponent()
|
||||||
@ -105,8 +108,6 @@ void APlayerCharacter::OnDeath(FDamageInfo damageInfo)
|
|||||||
{
|
{
|
||||||
UGameplayStatics::PlaySoundAtLocation(GetWorld(), OnDeathSound, GetActorLocation());
|
UGameplayStatics::PlaySoundAtLocation(GetWorld(), OnDeathSound, GetActorLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: End the game
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void APlayerCharacter::CameraShakeTimelineCallback(float val)
|
void APlayerCharacter::CameraShakeTimelineCallback(float val)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user