Compare commits
5 Commits
ae416d5673
...
6ba42fd400
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ba42fd400 | |||
| 5e46f162d1 | |||
| abcd8acc6f | |||
| f3567a115e | |||
| a75cc548a7 |
|
|
@ -63,3 +63,15 @@ ServerDefaultMap=/Engine/Maps/Entry.Entry
|
||||||
GlobalDefaultGameMode=/Game/Blueprints/Game/BP_ExoGameMode.BP_ExoGameMode_C
|
GlobalDefaultGameMode=/Game/Blueprints/Game/BP_ExoGameMode.BP_ExoGameMode_C
|
||||||
GlobalDefaultServerGameMode=None
|
GlobalDefaultServerGameMode=None
|
||||||
|
|
||||||
|
|
||||||
|
[CoreRedirects]
|
||||||
|
+FunctionRedirects=(OldName="/Script/Exo.ExoPlayerController.UpdateCoverStandHeight",NewName="/Script/Exo.ExoPlayerController.UpdateSmoothCoverCamera")
|
||||||
|
+FunctionRedirects=(OldName="/Script/Exo.ExoPlayerController.AdjustCameraWhileInCover",NewName="/Script/Exo.ExoPlayerController.CalculateCoverAim")
|
||||||
|
+FunctionRedirects=(OldName="/Script/Exo.ExoPlayerController.SetNewCameraLocationOffset",NewName="/Script/Exo.ExoPlayerController.SetEyePositionOffset")
|
||||||
|
+FunctionRedirects=(OldName="/Script/Exo.ExoPlayerController.SetNewCameraRotationOffset",NewName="/Script/Exo.ExoPlayerController.SetEyeRoll")
|
||||||
|
+PropertyRedirects=(OldName="/Script/Exo.ExoPlayerCharacter.IsInCover",NewName="/Script/Exo.ExoPlayerCharacter.bIsInCover")
|
||||||
|
+PropertyRedirects=(OldName="/Script/Exo.ExoPlayerCharacter.CoverEyeHeight",NewName="/Script/Exo.ExoPlayerCharacter.LowEyeHeight")
|
||||||
|
+FunctionRedirects=(OldName="/Script/Exo.ExoPlayerController.CalculateCoverAim",NewName="/Script/Exo.ExoPlayerController.CalculateCoverAimOffset")
|
||||||
|
+PropertyRedirects=(OldName="/Script/Exo.ExoPlayerController.UseEyeHeight",NewName="/Script/Exo.ExoPlayerController.bUseEyeHeight")
|
||||||
|
+FunctionRedirects=(OldName="/Script/Exo.ExoPlayerCharacter.SetEyePositionOffset",NewName="/Script/Exo.ExoPlayerCharacter.SetEyePositionOffsetTarget")
|
||||||
|
+FunctionRedirects=(OldName="/Script/Exo.ExoPlayerCharacter.UnCrouchCustom",NewName="/Script/Exo.ExoPlayerCharacter.TryUnCrouchCustom")
|
||||||
Binary file not shown.
BIN
Content/Blueprints/HeightChecker.uasset
Normal file
BIN
Content/Blueprints/HeightChecker.uasset
Normal file
Binary file not shown.
Binary file not shown.
BIN
Content/Blueprints/Player/CF_Crouch.uasset
Normal file
BIN
Content/Blueprints/Player/CF_Crouch.uasset
Normal file
Binary file not shown.
BIN
Content/Blueprints/Testing/HeightChecker.uasset
Normal file
BIN
Content/Blueprints/Testing/HeightChecker.uasset
Normal file
Binary file not shown.
Binary file not shown.
|
|
@ -265,6 +265,7 @@ void UShootingComponent::StartAiming()
|
||||||
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed * AimingMoveSpeedScale;
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed * AimingMoveSpeedScale;
|
||||||
|
|
||||||
TargetFOV = CurrentGunBase->AimingFOV;
|
TargetFOV = CurrentGunBase->AimingFOV;
|
||||||
|
OnStartedADS.Broadcast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -274,6 +275,8 @@ void UShootingComponent::StopAiming()
|
||||||
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
|
||||||
|
|
||||||
TargetFOV = DefaultFOV;
|
TargetFOV = DefaultFOV;
|
||||||
|
|
||||||
|
OnStoppedADS.Broadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UShootingComponent::Throw()
|
void UShootingComponent::Throw()
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,29 @@
|
||||||
|
|
||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
#include "Characters/Components/ShootingComponent.h"
|
#include "Characters/Components/ShootingComponent.h"
|
||||||
|
#include "Components/CapsuleComponent.h"
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "Items/AmmoBoxBase.h"
|
#include "Items/AmmoBoxBase.h"
|
||||||
#include "Items/HealthBoxBase.h"
|
#include "Items/HealthBoxBase.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
|
||||||
#include "Player/InteractionComponent.h"
|
#include "Player/InteractionComponent.h"
|
||||||
#include "Widget/WBP_PlayerUI.h"
|
#include "Widget/WBP_PlayerUI.h"
|
||||||
|
|
||||||
|
|
||||||
AExoPlayerCharacter::AExoPlayerCharacter()
|
AExoPlayerCharacter::AExoPlayerCharacter()
|
||||||
{
|
{
|
||||||
|
PrimaryActorTick.bCanEverTick = true;
|
||||||
|
|
||||||
|
// Setup eye height values
|
||||||
|
StandingEyeHeight = 175.f;
|
||||||
|
CrouchedEyeHeight = 50.f;
|
||||||
|
LowEyeHeightOffset = -20.f;
|
||||||
|
|
||||||
|
// Create camera component
|
||||||
|
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
|
||||||
|
CameraComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
|
||||||
|
CameraComponent->bUsePawnControlRotation = true;
|
||||||
|
|
||||||
|
|
||||||
GetCharacterMovement()->bSnapToPlaneAtStart = true;
|
GetCharacterMovement()->bSnapToPlaneAtStart = true;
|
||||||
|
|
||||||
InteractionComponent = CreateDefaultSubobject<UInteractionComponent>(TEXT("Interaction Component"));
|
InteractionComponent = CreateDefaultSubobject<UInteractionComponent>(TEXT("Interaction Component"));
|
||||||
|
|
@ -30,21 +43,25 @@ AExoPlayerCharacter::AExoPlayerCharacter()
|
||||||
//bUseControllerRotationPitch = false;
|
//bUseControllerRotationPitch = false;
|
||||||
//bUseControllerRotationYaw = true;
|
//bUseControllerRotationYaw = true;
|
||||||
//bUseControllerRotationRoll = false;
|
//bUseControllerRotationRoll = false;
|
||||||
|
|
||||||
// Setup camera component
|
|
||||||
CameraComponent = CreateDefaultSubobject<UCameraComponent>(TEXT("CameraComponent"));
|
|
||||||
CameraComponent->AttachToComponent(RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
|
|
||||||
CameraComponent->bUsePawnControlRotation = true;
|
|
||||||
CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, BaseEyeHeight));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExoPlayerCharacter::BeginPlay()
|
void AExoPlayerCharacter::BeginPlay()
|
||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
// Set correct starting camera height
|
||||||
|
SetTargetEyeHeight(StandingEyeHeight);
|
||||||
|
CameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, TargetEyeHeight + GetFootOffset()));
|
||||||
|
|
||||||
GetCapsuleComponent()->OnComponentBeginOverlap.AddDynamic(this, &AExoPlayerCharacter::OnActorBeginOverlap);
|
GetCapsuleComponent()->OnComponentBeginOverlap.AddDynamic(this, &AExoPlayerCharacter::OnActorBeginOverlap);
|
||||||
//UGameplayStatics::GetPlayerCameraManager(GetWorld(), 0)->SetViewTarget(this);
|
|
||||||
StandingEyeHeight = CameraComponent->GetRelativeLocation().Z;
|
// Setup crouch timeline
|
||||||
|
FOnTimelineFloat ProgressUpdate;
|
||||||
|
ProgressUpdate.BindUFunction(this, FName("CrouchingUpdate"));
|
||||||
|
FOnTimelineEvent FinishedEvent;
|
||||||
|
FinishedEvent.BindUFunction(this, FName("CrouchingFinished"));
|
||||||
|
CrouchTimeline.AddInterpFloat(CapsuleResizeCurve, ProgressUpdate);
|
||||||
|
CrouchTimeline.SetTimelineFinishedFunc(FinishedEvent);
|
||||||
|
|
||||||
|
|
||||||
PlayerHud = CreateWidget<UWBP_PlayerUI>(GetWorld(),PlayerHudClass);
|
PlayerHud = CreateWidget<UWBP_PlayerUI>(GetWorld(),PlayerHudClass);
|
||||||
|
|
@ -64,8 +81,89 @@ void AExoPlayerCharacter::BeginPlay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::Tick(float DeltaTime)
|
||||||
|
{
|
||||||
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
|
CrouchTimeline.TickTimeline(2*DeltaTime);
|
||||||
|
|
||||||
|
UpdateCameraHeight(DeltaTime);
|
||||||
|
ApplyCameraOffsets(DeltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
float AExoPlayerCharacter::GetFootOffset()
|
||||||
|
{
|
||||||
|
return -GetCapsuleComponent()->GetScaledCapsuleHalfHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::CrouchingUpdate(float Alpha)
|
||||||
|
{
|
||||||
|
float CurrentCamHeight = GetCurrentEyeHeight();
|
||||||
|
|
||||||
|
float NewHalfHeight = FMath::Lerp(
|
||||||
|
StandingHalfHeight, GetCharacterMovement()->CrouchedHalfHeight, Alpha);
|
||||||
|
GetCapsuleComponent()->SetCapsuleHalfHeight(NewHalfHeight);
|
||||||
|
|
||||||
|
CameraComponent->SetRelativeLocation(
|
||||||
|
FVector(0, 0, GetFootOffset()) +
|
||||||
|
FVector(0, 0, CurrentCamHeight));
|
||||||
|
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Crouching Update"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::CrouchingFinished()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::UpdateCameraHeight(float DeltaTime)
|
||||||
|
{
|
||||||
|
if (FMath::IsNearlyEqual(GetCurrentEyeHeight(), TargetEyeHeight, 0.01f))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const float NewHeight = FMath::Lerp(GetCurrentEyeHeight(), TargetEyeHeight, DeltaTime*5);
|
||||||
|
const FVector CamRelXY = CameraComponent->GetRelativeLocation();
|
||||||
|
EyeHeight = GetFootOffset() + NewHeight;
|
||||||
|
CameraComponent->SetRelativeLocation(FVector(CamRelXY.X, CamRelXY.Y,EyeHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::ApplyCameraOffsets(float DeltaTime)
|
||||||
|
{
|
||||||
|
bool HasChanged = false;
|
||||||
|
if (!FVector::PointsAreNear(EyeLocationOffset, TargetEyeLocationOffset, 0.01f))
|
||||||
|
{
|
||||||
|
// Smoothly offset view
|
||||||
|
EyeLocationOffset = FMath::Lerp(EyeLocationOffset, TargetEyeLocationOffset, 5*DeltaTime);
|
||||||
|
HasChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!FMath::IsNearlyEqual(EyeRoll, TargetEyeRoll, 0.01f))
|
||||||
|
{
|
||||||
|
// Smoothly rotate view
|
||||||
|
EyeRoll = FMath::Lerp(EyeRoll, TargetEyeRoll, DeltaTime*5);
|
||||||
|
HasChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!HasChanged)
|
||||||
|
{
|
||||||
|
// Do not calculate anything if nothing changed
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update actual camera position
|
||||||
|
const FVector FinalOffset = FVector(EyeLocationOffset.X, EyeLocationOffset.Y,
|
||||||
|
EyeLocationOffset.Z + TargetEyeHeight + GetFootOffset());
|
||||||
|
CameraComponent->SetRelativeLocation(FinalOffset);
|
||||||
|
|
||||||
|
// Update actual camera rotation (Roll)
|
||||||
|
FRotator NewRotator = GetController()->GetControlRotation();
|
||||||
|
NewRotator.Roll = EyeRoll;
|
||||||
|
GetController()->SetControlRotation(NewRotator);
|
||||||
|
}
|
||||||
|
|
||||||
void AExoPlayerCharacter::OnActorBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
|
void AExoPlayerCharacter::OnActorBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
|
||||||
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
|
||||||
{
|
{
|
||||||
if (OtherActor && OtherActor != this)
|
if (OtherActor && OtherActor != this)
|
||||||
{
|
{
|
||||||
|
|
@ -96,6 +194,34 @@ void AExoPlayerCharacter::OnActorBeginOverlap(UPrimitiveComponent* OverlappedCom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::CrouchCustom()
|
||||||
|
{
|
||||||
|
SetTargetEyeHeight(CrouchedEyeHeight);
|
||||||
|
GetCharacterMovement()->MaxWalkSpeed = CrouchSpeed;
|
||||||
|
bIsCrouched = true;
|
||||||
|
CrouchTimeline.Play();
|
||||||
|
|
||||||
|
//float CurrentCamHeight = GetCurrentEyeHeight();
|
||||||
|
//GetCapsuleComponent()->SetCapsuleHalfHeight(GetCharacterMovement()->CrouchedHalfHeight);
|
||||||
|
// CameraComponent->SetRelativeLocation(
|
||||||
|
// FVector(0, 0, GetFootOffset()) +
|
||||||
|
// FVector(0, 0, CurrentCamHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::TryUnCrouchCustom()
|
||||||
|
{
|
||||||
|
SetTargetEyeHeight(StandingEyeHeight);
|
||||||
|
GetCharacterMovement()->MaxWalkSpeed = WalkSpeed;
|
||||||
|
bIsCrouched = false;
|
||||||
|
CrouchTimeline.Reverse();
|
||||||
|
|
||||||
|
//float CurrentCamHeight = GetCurrentEyeHeight();
|
||||||
|
//GetCapsuleComponent()->SetCapsuleHalfHeight(StandingHalfHeight);
|
||||||
|
//CameraComponent->SetRelativeLocation(
|
||||||
|
// FVector(0, 0, GetFootOffset()) +
|
||||||
|
// FVector(0, 0, CurrentCamHeight));
|
||||||
|
}
|
||||||
|
|
||||||
void AExoPlayerCharacter::AddHealthPoints(float addValue)
|
void AExoPlayerCharacter::AddHealthPoints(float addValue)
|
||||||
{
|
{
|
||||||
CurrentHealth += addValue;
|
CurrentHealth += addValue;
|
||||||
|
|
@ -106,3 +232,63 @@ void AExoPlayerCharacter::AddHealthPoints(float addValue)
|
||||||
if (PlayerHud)
|
if (PlayerHud)
|
||||||
PlayerHud->SetHp(CurrentHealth,MaxHealth);
|
PlayerHud->SetHp(CurrentHealth,MaxHealth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float AExoPlayerCharacter::GetStandingEyeHeight(const bool bCapsuleRelative) const
|
||||||
|
{
|
||||||
|
return bCapsuleRelative ? StandingEyeHeight - GetCapsuleComponent()->GetScaledCapsuleHalfHeight()
|
||||||
|
: StandingEyeHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
float AExoPlayerCharacter::GetCrouchingEyeHeight(const bool bCapsuleRelative) const
|
||||||
|
{
|
||||||
|
return bCapsuleRelative ? CrouchedEyeHeight - GetCapsuleComponent()->GetScaledCapsuleHalfHeight()
|
||||||
|
: CrouchedEyeHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AExoPlayerCharacter::IsCrouching() const
|
||||||
|
{
|
||||||
|
return bIsCrouched;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::SetEyePositionOffsetTarget(const FVector LocationOffset)
|
||||||
|
{
|
||||||
|
//LocationOffset.Z = FMath::Clamp(LocationOffset.Z, CoverEyeHeight, StandingEyeHeight);
|
||||||
|
UE_LOG(LogTemp, Log, TEXT("Eye offset set to: %s"), *LocationOffset.ToString());
|
||||||
|
TargetEyeLocationOffset = LocationOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::SetEyeRoll(float RollValue)
|
||||||
|
{
|
||||||
|
TargetEyeRoll = RollValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector AExoPlayerCharacter::GetPlayerLocationAtFeet() const
|
||||||
|
{
|
||||||
|
FVector ReturnVector = GetActorLocation();
|
||||||
|
ReturnVector.Z -= GetCapsuleComponent()->GetScaledCapsuleHalfHeight();
|
||||||
|
return ReturnVector;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AExoPlayerCharacter::SetTargetEyeHeight(float NewEyeHeight, const bool bCapsuleRelative)
|
||||||
|
{
|
||||||
|
if (bCapsuleRelative)
|
||||||
|
{
|
||||||
|
NewEyeHeight += GetCapsuleComponent()->GetScaledCapsuleHalfHeight();
|
||||||
|
}
|
||||||
|
UE_LOG(LogTemp, Log, TEXT("Target eye height set to: %f"), NewEyeHeight);
|
||||||
|
TargetEyeHeight = FMath::Clamp(NewEyeHeight,
|
||||||
|
CrouchedEyeHeight + LowEyeHeightOffset, StandingEyeHeight
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
float AExoPlayerCharacter::GetCurrentEyeHeight(const bool bCapsuleRelative) const
|
||||||
|
{
|
||||||
|
float ReturnValue = CameraComponent->GetRelativeLocation().Z;
|
||||||
|
if (!bCapsuleRelative)
|
||||||
|
{
|
||||||
|
ReturnValue += GetCapsuleComponent()->GetScaledCapsuleHalfHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ReturnValue;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
#include "EnhancedInputComponent.h"
|
#include "EnhancedInputComponent.h"
|
||||||
#include "EnhancedInputSubsystems.h"
|
#include "EnhancedInputSubsystems.h"
|
||||||
#include "Characters/ExoPlayerCharacter.h"
|
#include "Characters/ExoPlayerCharacter.h"
|
||||||
|
#include "Components/CapsuleComponent.h"
|
||||||
#include "GameFramework/Character.h"
|
#include "GameFramework/Character.h"
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "Kismet/GameplayStatics.h"
|
|
||||||
|
|
||||||
AExoPlayerController::AExoPlayerController()
|
AExoPlayerController::AExoPlayerController()
|
||||||
{
|
{
|
||||||
|
|
@ -29,33 +29,32 @@ void AExoPlayerController::BeginPlay()
|
||||||
Subsystem->AddMappingContext(InputContext, 0);
|
Subsystem->AddMappingContext(InputContext, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//InteractionComponent = PlayerCharacter->FindComponentByClass<UInteractionComponent>();
|
|
||||||
//ShootingComponent = PlayerCharacter->FindComponentByClass<UShootingComponent>();
|
|
||||||
InteractionComponent = PlayerCharacter->InteractionComponent;
|
InteractionComponent = PlayerCharacter->InteractionComponent;
|
||||||
ShootingComponent = PlayerCharacter->ShootingComponent;
|
ShootingComponent = PlayerCharacter->ShootingComponent;
|
||||||
|
|
||||||
// Ustawianie w komponencie poruszania pr<70>dko<6B>ci zapisanej w characterze
|
// Ustawianie w komponencie poruszania pr<70>dko<6B>ci zapisanej w characterze
|
||||||
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed;
|
||||||
|
|
||||||
// Oblicz prawidłową maksymalną wysokość na którą można wychylić się z nad osłony
|
|
||||||
|
|
||||||
UE_LOG(LogTemp, Display, TEXT("MaxCoverAimHeight: %f"), MaxCoverAimHeight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExoPlayerController::PlayerTick(float DeltaTime)
|
void AExoPlayerController::PlayerTick(const float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::PlayerTick(DeltaTime);
|
Super::PlayerTick(DeltaTime);
|
||||||
|
|
||||||
// TESTING
|
bIsCoverAiming = (PlayerCharacter->bIsInCover && PlayerCharacter->bIsAimingMode);
|
||||||
if (bIsInCover)
|
|
||||||
{
|
|
||||||
AdjustCameraWhileInCover();
|
|
||||||
}
|
|
||||||
UpdateCoverStandHeight(DeltaTime);
|
|
||||||
|
|
||||||
|
if (bIsCoverAiming)
|
||||||
|
{
|
||||||
|
CoverAimHeightOffset = CalculateCoverAimOffset();
|
||||||
|
PlayerCharacter->SetEyePositionOffsetTarget(FVector(0.f, 0.f, CoverAimHeightOffset));
|
||||||
|
}
|
||||||
|
|
||||||
|
// On screen cover state DEBUG
|
||||||
if (bShowCoverSystemDebug)
|
if (bShowCoverSystemDebug)
|
||||||
{
|
{
|
||||||
GEngine->AddOnScreenDebugMessage(2, -1, FColor::Red, FString::Printf(TEXT("In cover: %s"), bIsInCover ? "true" : "false"));
|
GEngine->AddOnScreenDebugMessage(2, -1, FColor::Red,
|
||||||
|
FString::Printf(TEXT("In cover: %hs"),
|
||||||
|
PlayerCharacter->bIsInCover ? "true" : "false")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,6 +118,8 @@ void AExoPlayerController::Interact()
|
||||||
|
|
||||||
void AExoPlayerController::PlayerJump()
|
void AExoPlayerController::PlayerJump()
|
||||||
{
|
{
|
||||||
|
if (PlayerCharacter->IsCrouching()) return;
|
||||||
|
|
||||||
PlayerCharacter->Jump();
|
PlayerCharacter->Jump();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -152,21 +153,17 @@ void AExoPlayerController::ResetDodge()
|
||||||
|
|
||||||
void AExoPlayerController::PlayerStartCrouch()
|
void AExoPlayerController::PlayerStartCrouch()
|
||||||
{
|
{
|
||||||
if (bIsSprinting)
|
if (bIsSprinting && !bWasSliding)
|
||||||
{
|
{
|
||||||
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeedCrouched = PlayerCharacter->SlideSpeed;
|
StartSlide();
|
||||||
GetWorldTimerManager().SetTimer(SlideCooldownTimer, this, &AExoPlayerController::ResetSlide, PlayerCharacter->SlideCooldown, false);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerCharacter->Crouch();
|
bWasSliding = false;
|
||||||
PlayerCharacter->CameraComponent->SetRelativeLocation(FVector(
|
PlayerCharacter->CrouchCustom();
|
||||||
0.0f,
|
|
||||||
0.0f,
|
|
||||||
PlayerCharacter->CrouchedEyeHeight)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Start checking for cover
|
// Start checking for cover
|
||||||
bIsInCover = CheckForCover();
|
PlayerCharacter->bIsInCover = CheckForCover();
|
||||||
GetWorld()->GetTimerManager().SetTimer(
|
GetWorld()->GetTimerManager().SetTimer(
|
||||||
CoverCheckTimer,
|
CoverCheckTimer,
|
||||||
this,
|
this,
|
||||||
|
|
@ -178,22 +175,28 @@ void AExoPlayerController::PlayerStartCrouch()
|
||||||
|
|
||||||
void AExoPlayerController::PlayerStopCrouch()
|
void AExoPlayerController::PlayerStopCrouch()
|
||||||
{
|
{
|
||||||
PlayerCharacter->UnCrouch();
|
PlayerCharacter->TryUnCrouchCustom();
|
||||||
PlayerCharacter->CameraComponent->SetRelativeLocation(FVector(
|
|
||||||
0.0f,
|
|
||||||
0.0f,
|
|
||||||
PlayerCharacter->BaseEyeHeight)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Stop checking for cover
|
// Stop checking for cover
|
||||||
GetWorld()->GetTimerManager().ClearTimer(CoverCheckTimer);
|
GetWorld()->GetTimerManager().ClearTimer(CoverCheckTimer);
|
||||||
bIsInCover = false;
|
PlayerCharacter->bIsInCover = false;
|
||||||
TargetCoverStandAlpha = 0.0f;
|
}
|
||||||
|
|
||||||
|
void AExoPlayerController::StartSlide()
|
||||||
|
{
|
||||||
|
bIsSliding = true;
|
||||||
|
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->SlideSpeed;
|
||||||
|
PlayerCharacter->SetTargetEyeHeight(PlayerCharacter->LowEyeHeightOffset);
|
||||||
|
GetWorldTimerManager().SetTimer(SlideCooldownTimer, this, &AExoPlayerController::ResetSlide, PlayerCharacter->SlideCooldown, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExoPlayerController::ResetSlide()
|
void AExoPlayerController::ResetSlide()
|
||||||
{
|
{
|
||||||
PlayerCharacter->GetCharacterMovement()->MaxWalkSpeedCrouched = PlayerCharacter->CrouchSpeed;
|
bIsSliding = false;
|
||||||
|
bWasSliding = true;
|
||||||
|
PlayerStartCrouch();
|
||||||
|
//PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->CrouchSpeed;
|
||||||
|
//PlayerCharacter->SetTargetEyeHeight(PlayerCharacter->CrouchedEyeHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExoPlayerController::PlayerStartSprint()
|
void AExoPlayerController::PlayerStartSprint()
|
||||||
|
|
@ -236,6 +239,10 @@ void AExoPlayerController::PlayerStartAim()
|
||||||
void AExoPlayerController::PlayerStopAim()
|
void AExoPlayerController::PlayerStopAim()
|
||||||
{
|
{
|
||||||
ShootingComponent->StopAiming();
|
ShootingComponent->StopAiming();
|
||||||
|
if (PlayerCharacter->bIsInCover)
|
||||||
|
{
|
||||||
|
PlayerCharacter->SetEyePositionOffsetTarget(FVector(0, 0, 0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExoPlayerController::PlayerMeleAttack()
|
void AExoPlayerController::PlayerMeleAttack()
|
||||||
|
|
@ -270,13 +277,13 @@ void AExoPlayerController::PlayerReload()
|
||||||
|
|
||||||
bool AExoPlayerController::CheckForCover()
|
bool AExoPlayerController::CheckForCover()
|
||||||
{
|
{
|
||||||
// Cover is recalculated every time the player crouches or stops moving while crouched
|
|
||||||
// Cover targets are cleared completely when player stands up again or dies
|
|
||||||
|
|
||||||
// Do a simple 8-directional line trace
|
// Do a simple 8-directional line trace
|
||||||
FVector TraceDirection = PlayerCharacter->GetActorForwardVector();
|
FVector TraceDirection = PlayerCharacter->GetActorForwardVector();
|
||||||
FVector TraceStart = PlayerCharacter->GetActorLocation();
|
FVector TraceStart = PlayerCharacter->GetActorLocation();
|
||||||
TraceStart.Z -= PlayerCharacter->GetCapsuleComponent()->GetScaledCapsuleHalfHeight() - CoverObstacleMinHeight;
|
TraceStart.Z += bUseEyeHeight ?
|
||||||
|
PlayerCharacter->GetCrouchingEyeHeight(true)
|
||||||
|
:
|
||||||
|
PlayerCharacter->GetPlayerLocationAtFeet().Z + CoverObstacleMinHeight;
|
||||||
FCollisionQueryParams QueryParams;
|
FCollisionQueryParams QueryParams;
|
||||||
QueryParams.AddIgnoredActor(PlayerCharacter);
|
QueryParams.AddIgnoredActor(PlayerCharacter);
|
||||||
|
|
||||||
|
|
@ -306,10 +313,8 @@ bool AExoPlayerController::CheckForCover()
|
||||||
// Check if this particular hit isn't against a wall (>CoverMaxHeight)
|
// Check if this particular hit isn't against a wall (>CoverMaxHeight)
|
||||||
|
|
||||||
FHitResult SphereHit;
|
FHitResult SphereHit;
|
||||||
FVector SpherePosition = Hit.ImpactPoint +
|
FVector SpherePosition = Hit.ImpactPoint;
|
||||||
FVector(
|
SpherePosition.Z = PlayerCharacter->GetPlayerLocationAtFeet().Z + CoverObstacleMaxHeight + CoverAimWindowRadius;
|
||||||
0.0f, 0.0f,
|
|
||||||
CoverObstacleMaxHeight + CoverAimWindowRadius - CoverObstacleMinHeight);
|
|
||||||
|
|
||||||
GetWorld()->SweepSingleByChannel(
|
GetWorld()->SweepSingleByChannel(
|
||||||
SphereHit,
|
SphereHit,
|
||||||
|
|
@ -342,20 +347,17 @@ bool AExoPlayerController::CheckForCover()
|
||||||
return ValidHits.Num() > 0;
|
return ValidHits.Num() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExoPlayerController::AdjustCameraWhileInCover()
|
float AExoPlayerController::CalculateCoverAimOffset()
|
||||||
{
|
{
|
||||||
if (!bIsInCover)
|
// Nic nie rób jak nie znajdujesz się za osłoną
|
||||||
|
if (!PlayerCharacter->bIsInCover)
|
||||||
{
|
{
|
||||||
return;
|
return 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaxCoverAimHeight = PlayerCharacter->StandingEyeHeight * CoverAimStandFactor;
|
// Oblicz maksymalną wysokość, na którą można wychylić się znad osłony
|
||||||
|
MaxCoverAimHeight = PlayerCharacter->GetStandingEyeHeight() * CoverAimStandFactor;
|
||||||
|
|
||||||
//FVector StartOffset = GetCharacter()->GetActorForwardVector() * 20.0f;
|
|
||||||
FVector ObstacleTraceStart = GetCharacter()->GetActorLocation();
|
|
||||||
ObstacleTraceStart.Z += GetCharacter()->CrouchedEyeHeight;
|
|
||||||
FVector ObstacleTraceEnd =
|
|
||||||
ObstacleTraceStart + PlayerCameraManager->GetCameraRotation().Vector() * CoverAimFreeDistance;
|
|
||||||
FCollisionQueryParams QueryParams;
|
FCollisionQueryParams QueryParams;
|
||||||
QueryParams.AddIgnoredActor(PlayerCharacter);
|
QueryParams.AddIgnoredActor(PlayerCharacter);
|
||||||
TEnumAsByte<ECollisionChannel> ObstacleTraceChannel = ECC_WorldStatic;
|
TEnumAsByte<ECollisionChannel> ObstacleTraceChannel = ECC_WorldStatic;
|
||||||
|
|
@ -363,159 +365,62 @@ void AExoPlayerController::AdjustCameraWhileInCover()
|
||||||
FHitResult Hit;
|
FHitResult Hit;
|
||||||
bool bFreeSpace = false;
|
bool bFreeSpace = false;
|
||||||
|
|
||||||
// Trace until no hit is found (free space to aim)
|
FVector ObstacleTraceStart = PlayerCharacter->GetPlayerLocationAtFeet();
|
||||||
for (int i = 0; i < MaxCoverAimHeight; i += 2*CoverAimWindowRadius)
|
ObstacleTraceStart.Z += PlayerCharacter->CrouchedEyeHeight;
|
||||||
|
FVector ObstacleTraceEnd = ObstacleTraceStart + PlayerCameraManager->GetCameraRotation().Vector() * CoverAimFreeDistance;
|
||||||
|
|
||||||
|
float SafeCoverAimZOffset = 0.f;
|
||||||
|
while (SafeCoverAimZOffset < MaxCoverAimHeight)
|
||||||
{
|
{
|
||||||
ObstacleTraceStart.Z += i;
|
ObstacleTraceStart.Z += SafeCoverAimZOffset;
|
||||||
ObstacleTraceEnd.Z += i;
|
ObstacleTraceEnd.Z += SafeCoverAimZOffset;
|
||||||
|
|
||||||
GetWorld()->SweepSingleByChannel(
|
GetWorld()->SweepSingleByChannel(
|
||||||
Hit,
|
Hit,
|
||||||
ObstacleTraceStart,
|
ObstacleTraceStart,
|
||||||
ObstacleTraceEnd,
|
ObstacleTraceEnd,
|
||||||
FQuat::Identity,
|
FQuat::Identity,
|
||||||
ObstacleTraceChannel,
|
ObstacleTraceChannel,
|
||||||
FCollisionShape::MakeSphere(CoverAimWindowRadius),
|
FCollisionShape::MakeSphere(CoverAimWindowRadius),
|
||||||
QueryParams
|
QueryParams
|
||||||
);
|
);
|
||||||
|
|
||||||
if (bShowCoverSystemDebug)
|
if (Hit.bBlockingHit == true)
|
||||||
{
|
{
|
||||||
DrawDebugSphere(GetWorld(), Hit.Location, CoverAimWindowRadius, 8,
|
// Increment check height every failed iteration
|
||||||
Hit.bBlockingHit ? FColor::Blue : FColor::Red,
|
SafeCoverAimZOffset += 0.2f;
|
||||||
false, 0.0f, 0, 0);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (Hit.bBlockingHit == false)
|
|
||||||
{
|
{
|
||||||
UE_LOG(LogTemp, Display, TEXT("Free space"));
|
// Break the loop if free space found
|
||||||
bFreeSpace = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bFreeSpace)
|
const float FinalHitHeight = Hit.TraceStart.Z - PlayerCharacter->GetPlayerLocationAtFeet().Z;
|
||||||
|
// If this is true that means that free space was found
|
||||||
|
if (FinalHitHeight <= MaxCoverAimHeight)
|
||||||
{
|
{
|
||||||
TargetCoverStandAlpha = FMath::GetMappedRangeValueClamped(
|
PlayerCharacter->bIsCrouched = false;
|
||||||
UE::Math::TVector2<float>(GetCharacter()->CrouchedEyeHeight, GetCharacter()->CrouchedEyeHeight + MaxCoverAimHeight),
|
//// DEBUG ////
|
||||||
UE::Math::TVector2(0.0f, 1.0f),
|
|
||||||
Hit.TraceStart.Z
|
|
||||||
);
|
|
||||||
if (bShowCoverSystemDebug)
|
if (bShowCoverSystemDebug)
|
||||||
{
|
{
|
||||||
DrawDebugLine(GetWorld(), Hit.TraceStart, Hit.TraceEnd, FColor::Red);
|
DrawDebugLine(GetWorld(), Hit.TraceStart, Hit.TraceEnd, FColor::Purple);
|
||||||
}
|
}
|
||||||
|
//////////////
|
||||||
|
|
||||||
|
return FinalHitHeight - PlayerCharacter->CrouchedEyeHeight;// +
|
||||||
|
//PlayerCharacter->CrouchedEyeHeight - PlayerCharacter->GetCurrentEyeHeight();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return 0 offset if no free space to aim was found
|
||||||
|
//return 0.f;
|
||||||
// IDEA FOR A MORE COMPLEX SYSTEM IN THE FUTURE:
|
return MaxCoverAimHeight - PlayerCharacter->CrouchedEyeHeight;
|
||||||
//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
|
||||||
// To not introduce accidental flickering and optimize it a bit, all of this should run
|
|
||||||
// ONLY on cover update
|
|
||||||
|
|
||||||
// FVector CrouchedEyeWorldPosition = PlayerCharacter->GetActorLocation();
|
|
||||||
// CrouchedEyeWorldPosition.Z += PlayerCharacter->CrouchedEyeHeight;
|
|
||||||
// FVector CoverCeiling = CrouchedEyeWorldPosition + MaxCoverAimHeight;
|
|
||||||
// float PlayerCapsuleRadius = PlayerCharacter->GetCapsuleComponent()->GetScaledCapsuleHalfHeight();
|
|
||||||
// TEnumAsByte<ECollisionChannel> ObstacleTraceChannel = ECC_WorldStatic;
|
|
||||||
// FCollisionQueryParams QueryParams;
|
|
||||||
// QueryParams.AddIgnoredActor(PlayerCharacter);
|
|
||||||
//
|
|
||||||
// // Shoot ray up at maximum cover length to determine how high the player can "stand up"
|
|
||||||
// FHitResult WallTopHit;
|
|
||||||
// GetWorld()->SweepSingleByChannel(
|
|
||||||
// WallTopHit,
|
|
||||||
// CrouchedEyeWorldPosition,
|
|
||||||
// CoverCeiling,
|
|
||||||
// FQuat::Identity,
|
|
||||||
// ObstacleTraceChannel,
|
|
||||||
// FCollisionShape::MakeSphere(PlayerCapsuleRadius),
|
|
||||||
// QueryParams
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// FVector CeilingWorldLocation;
|
|
||||||
// if (WallTopHit.bBlockingHit == true)
|
|
||||||
// {
|
|
||||||
// CeilingWorldLocation = WallTopHit.Location;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// CeilingWorldLocation = WallTopHit.TraceEnd;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // From hit location (or if no hit - from end position) shoot ray towards camera's forward
|
|
||||||
// // vector at minimum cover length
|
|
||||||
//
|
|
||||||
// constexpr float WallFinderDistance = 75.0f;
|
|
||||||
// FVector WallFinderDirection = PlayerCharacter->GetActorForwardVector();
|
|
||||||
// WallFinderDirection.Z = 0.0f; // Not needed if the player always stays upright
|
|
||||||
//
|
|
||||||
// GetWorld()->LineTraceSingleByChannel(
|
|
||||||
// WallTopHit,
|
|
||||||
// CeilingWorldLocation,
|
|
||||||
// CeilingWorldLocation + (WallFinderDirection * WallFinderDistance),
|
|
||||||
// ObstacleTraceChannel,
|
|
||||||
// QueryParams
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// // regardless of the hit result shoot multi-ray downwards from end location
|
|
||||||
// // with maximum cover length
|
|
||||||
//
|
|
||||||
// FVector WallTopTraceStart = WallTopHit.bBlockingHit ? WallTopHit.Location : WallTopHit.TraceEnd;
|
|
||||||
// TArray<FHitResult> ValidHitsCandidateArray;
|
|
||||||
//
|
|
||||||
// GetWorld()->LineTraceMultiByChannel(
|
|
||||||
// ValidHitsCandidateArray,
|
|
||||||
// WallTopTraceStart,
|
|
||||||
// WallTopTraceStart + (FVector(0.0f, 0.0f, 0.0f) * MaxCoverAimHeight),
|
|
||||||
// ObstacleTraceChannel,
|
|
||||||
// QueryParams
|
|
||||||
// );
|
|
||||||
|
|
||||||
// On every ray hit trace an in-place sphere to determine if the aiming spot is valid
|
|
||||||
|
|
||||||
// All valid aiming spots are collected and the lowest (smallest Z) is chosen
|
|
||||||
|
|
||||||
// Sphere trace from camera forward a certain distance to regulate camera position while
|
|
||||||
// aiming up and down // TODO: elaborate
|
|
||||||
}
|
|
||||||
|
|
||||||
void AExoPlayerController::UpdateCoverStandHeight(float DeltaTime)
|
|
||||||
{
|
|
||||||
// if (FMath::IsNearlyEqual(CoverStandAlpha, TargetCoverStandAlpha, 0.01f))
|
|
||||||
// {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
CoverStandAlpha = FMath::Lerp(CoverStandAlpha, TargetCoverStandAlpha, DeltaTime * 5.0f);
|
|
||||||
//CoverStandAlpha = TargetCoverStandAlpha;
|
|
||||||
|
|
||||||
// BANDAID SOLUTION
|
|
||||||
const float NewZ = FMath::Lerp(
|
|
||||||
PlayerCharacter->CrouchedEyeHeight,
|
|
||||||
PlayerCharacter->StandingEyeHeight,
|
|
||||||
CoverStandAlpha
|
|
||||||
);
|
|
||||||
|
|
||||||
PlayerCharacter->CameraComponent->SetRelativeLocation(
|
|
||||||
FVector(0.0f, 0.0f, NewZ)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (bShowCoverSystemDebug && GEngine)
|
|
||||||
{
|
|
||||||
GEngine->AddOnScreenDebugMessage(1, -1, FColor::Red, FString::Printf(TEXT("Current cover stand alpha: %f"), CoverStandAlpha));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExoPlayerController::OnCoverTimer()
|
void AExoPlayerController::OnCoverTimer()
|
||||||
{
|
{
|
||||||
bIsInCover = CheckForCover();
|
PlayerCharacter->bIsInCover = CheckForCover();
|
||||||
if (bIsInCover == false)
|
|
||||||
{
|
|
||||||
TargetCoverStandAlpha = 0.0f;
|
|
||||||
UpdateCoverStandHeight(GetWorld()->GetDeltaSeconds());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AExoPlayerController::DebugCoverSystem(bool show)
|
void AExoPlayerController::DebugCoverSystem(bool show)
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,10 @@ public:
|
||||||
AGunBase* SecondaryGunBase = nullptr;
|
AGunBase* SecondaryGunBase = nullptr;
|
||||||
UStaticMeshComponent* SecondaryGunMesh = nullptr;
|
UStaticMeshComponent* SecondaryGunMesh = nullptr;
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnADSEventSignature);
|
||||||
|
FOnADSEventSignature OnStartedADS;
|
||||||
|
FOnADSEventSignature OnStoppedADS;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ResetFireCooldown();
|
void ResetFireCooldown();
|
||||||
void ReloadCompleted();
|
void ReloadCompleted();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Camera/CameraComponent.h"
|
#include "Camera/CameraComponent.h"
|
||||||
#include "Characters/ExoCharacterBase.h"
|
#include "Characters/ExoCharacterBase.h"
|
||||||
#include "Components/CapsuleComponent.h"
|
#include "Components/TimelineComponent.h"
|
||||||
#include "ExoPlayerCharacter.generated.h"
|
#include "ExoPlayerCharacter.generated.h"
|
||||||
|
|
||||||
class UInteractionComponent;
|
class UInteractionComponent;
|
||||||
|
|
@ -20,6 +20,7 @@ class EXO_API AExoPlayerCharacter : public AExoCharacterBase
|
||||||
public:
|
public:
|
||||||
AExoPlayerCharacter();
|
AExoPlayerCharacter();
|
||||||
|
|
||||||
|
/// U PROPERTIES ///
|
||||||
UPROPERTY(EditAnywhere, Category = "Combat")
|
UPROPERTY(EditAnywhere, Category = "Combat")
|
||||||
TObjectPtr<USkeletalMeshComponent> Weapon;
|
TObjectPtr<USkeletalMeshComponent> Weapon;
|
||||||
|
|
||||||
|
|
@ -32,8 +33,11 @@ public:
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Camera")
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Camera")
|
||||||
TObjectPtr<UCameraComponent> CameraComponent;
|
TObjectPtr<UCameraComponent> CameraComponent;
|
||||||
|
|
||||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Camera")
|
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
|
||||||
float StandingEyeHeight;
|
TObjectPtr<USceneComponent> CapsuleBottom;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UI")
|
||||||
|
TSubclassOf<UUserWidget> PlayerHudClass;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
UPROPERTY(EditAnywhere, Category = "Dodge Properties")
|
||||||
float DodgeForce = 5000.f;
|
float DodgeForce = 5000.f;
|
||||||
|
|
@ -62,21 +66,109 @@ public:
|
||||||
UPROPERTY(EditAnywhere, Category = "Health")
|
UPROPERTY(EditAnywhere, Category = "Health")
|
||||||
float CurrentHealth = 50.0f;
|
float CurrentHealth = 50.0f;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UI")
|
/// Połowa wysokości kapsuły gracza podczas stania
|
||||||
TSubclassOf<UUserWidget> PlayerHudClass;
|
UPROPERTY(EditAnywhere, BlueprintReadOnly)
|
||||||
|
float StandingHalfHeight = 88.f;
|
||||||
|
|
||||||
|
/** Czy postać gracza jest obecnie schowana za osłoną */
|
||||||
|
UPROPERTY(BlueprintReadOnly, Category = "Cover System")
|
||||||
|
bool bIsInCover = false;
|
||||||
|
|
||||||
|
/** Offset kamery podczas leżenia (osłona, ślizg) <br>
|
||||||
|
* Bezpiecznie będzie założyć że to najniżej jak kamera
|
||||||
|
* może zejść podczas gameplaya
|
||||||
|
*/
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera")
|
||||||
|
float LowEyeHeightOffset;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere)
|
||||||
|
TObjectPtr<UCurveFloat> CapsuleResizeCurve;
|
||||||
|
|
||||||
|
|
||||||
|
/// U FUNCTIONS ///
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void OnActorBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
|
void OnActorBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp,
|
||||||
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult
|
int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// Przełącza gracza w tryb kucania
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Movement")
|
||||||
|
void CrouchCustom();
|
||||||
|
|
||||||
|
/// Próbuje wyjść z trybu kucania
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Movement")
|
||||||
|
void TryUnCrouchCustom();
|
||||||
|
|
||||||
|
DECLARE_MULTICAST_DELEGATE(FOnPlayerCrouchEvent);
|
||||||
|
FOnPlayerCrouchEvent OnPlayerCrouchStart;
|
||||||
|
FOnPlayerCrouchEvent OnPlayerCrouchStop;
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void AddHealthPoints(float addValue);
|
void AddHealthPoints(float addValue);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="Camera")
|
||||||
|
void SetEyePositionOffsetTarget(FVector LocationOffset);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="Camera")
|
||||||
|
void SetEyeRoll(float RollValue);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
FVector GetPlayerLocationAtFeet() const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="Camera")
|
||||||
|
void SetTargetEyeHeight(float NewEyeHeight, const bool bCapsuleRelative = false);
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category="Camera")
|
||||||
|
float GetCurrentEyeHeight(const bool bCapsuleRelative = false) const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, Category="Camera")
|
||||||
|
float GetStandingEyeHeight(const bool bCapsuleRelative = false) const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, Category="Camera")
|
||||||
|
float GetCrouchingEyeHeight(const bool bCapsuleRelative = false) const;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintPure, Category="Movement")
|
||||||
|
bool IsCrouching() const;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void BeginPlay() override;
|
virtual void BeginPlay() override;
|
||||||
|
|
||||||
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|
||||||
float MaxHealth = 100.0f;
|
float MaxHealth = 100.0f;
|
||||||
|
|
||||||
UWBP_PlayerUI* PlayerHud;
|
UWBP_PlayerUI* PlayerHud;
|
||||||
|
|
||||||
|
/** Wysokość kamery podczas kucania jest dostarczana przez Character.h*/
|
||||||
|
/** Wysokość kamery podczas stania <br>
|
||||||
|
* Też najwyższa wysokość na którą kamera może się wznieść
|
||||||
|
* podczas gameplaya
|
||||||
|
*/
|
||||||
|
UPROPERTY(EditAnywhere, Category="Camera")
|
||||||
|
float StandingEyeHeight;
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable)
|
||||||
|
float GetFootOffset();
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
FVector TargetEyeLocationOffset;
|
||||||
|
FVector EyeLocationOffset;
|
||||||
|
float TargetEyeRoll;
|
||||||
|
float EyeRoll;
|
||||||
|
|
||||||
|
float TargetEyeHeight;
|
||||||
|
float EyeHeight;
|
||||||
|
|
||||||
|
FTimeline CrouchTimeline;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void CrouchingUpdate(float Alpha);
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void CrouchingFinished();
|
||||||
|
|
||||||
|
void UpdateCameraHeight(float DeltaTime);
|
||||||
|
void ApplyCameraOffsets(float DeltaTime);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ public:
|
||||||
|
|
||||||
virtual void PlayerTick(float DeltaTime) override;
|
virtual void PlayerTick(float DeltaTime) override;
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly)
|
||||||
|
bool bIsCoverAiming = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void SetupInputComponent() override;
|
virtual void SetupInputComponent() override;
|
||||||
|
|
||||||
|
|
@ -53,6 +56,9 @@ protected:
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void PlayerStopCrouch(); // LCtrl\C\X
|
void PlayerStopCrouch(); // LCtrl\C\X
|
||||||
|
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Movement")
|
||||||
|
void StartSlide();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||||
void ResetSlide();
|
void ResetSlide();
|
||||||
|
|
||||||
|
|
@ -95,17 +101,9 @@ protected:
|
||||||
UFUNCTION(BlueprintCallable, Category = "Cover System")
|
UFUNCTION(BlueprintCallable, Category = "Cover System")
|
||||||
bool CheckForCover();
|
bool CheckForCover();
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Cover System")
|
//DECLARE_MULTICAST_DELEGATE(FOnPlayerAimEvent);
|
||||||
void AdjustCameraWhileInCover();
|
|
||||||
|
|
||||||
UFUNCTION(BlueprintCallable, Category = "Cover System")
|
// Cover System DEBUG
|
||||||
void UpdateCoverStandHeight(float DeltaTime);
|
|
||||||
|
|
||||||
void OnCoverTimer();
|
|
||||||
|
|
||||||
float MapAlphaToCoverStandHeight(float Alpha);
|
|
||||||
|
|
||||||
// DEBUG
|
|
||||||
UFUNCTION(Exec, Category = "Cover System")
|
UFUNCTION(Exec, Category = "Cover System")
|
||||||
void DebugCoverSystem(bool show);
|
void DebugCoverSystem(bool show);
|
||||||
bool bShowCoverSystemDebug = false;
|
bool bShowCoverSystemDebug = false;
|
||||||
|
|
@ -147,6 +145,9 @@ protected:
|
||||||
UPROPERTY(EditAnywhere, Category = "Movement properties")
|
UPROPERTY(EditAnywhere, Category = "Movement properties")
|
||||||
bool bIsSprinting = false;
|
bool bIsSprinting = false;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Movement properties")
|
||||||
|
bool bIsSliding = false;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Input")
|
UPROPERTY(EditAnywhere, Category = "Input")
|
||||||
TObjectPtr<UInputAction> ShootAction;
|
TObjectPtr<UInputAction> ShootAction;
|
||||||
|
|
||||||
|
|
@ -177,43 +178,40 @@ protected:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Character")
|
||||||
TObjectPtr<AExoPlayerCharacter> PlayerCharacter;
|
TObjectPtr<AExoPlayerCharacter> PlayerCharacter;
|
||||||
|
|
||||||
// Czy postać gracza jest obecnie schowana za osłoną
|
/** Częstotliwość okresowego szukania osłon podczas kucania */
|
||||||
UPROPERTY(EditAnywhere, Category = "Cover System")
|
|
||||||
bool bIsInCover = false;
|
|
||||||
|
|
||||||
/** Alpha wysokości kamery podczas wychulania zza osłony
|
|
||||||
* 0 - Wysokość kucania
|
|
||||||
* 1 - Maksymalna wysokość wychylenia określona przez CoverAimStandFactor
|
|
||||||
**/
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Cover System")
|
|
||||||
float TargetCoverStandAlpha = 0.0f;
|
|
||||||
|
|
||||||
// Częstotliwość okresowego szukania osłon podczas kucania
|
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
||||||
float CoverCheckRate = 0.5f;
|
float CoverCheckRate = 0.5f;
|
||||||
|
|
||||||
// Dystans na którym postać jest w stanie odnaleźć osłonę
|
/** Dystans na którym postać jest w stanie odnaleźć osłonę */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
||||||
float MaxDistanceFromCover = 50.0f;
|
float MaxDistanceFromCover = 50.0f;
|
||||||
|
|
||||||
// Minimalna wysokość przeszkody którą można określić osłoną
|
/** Używa wysokości oczu do określenia minimalnej wysokości przeszkody
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
* którą można określić osłoną
|
||||||
|
*/
|
||||||
|
UPROPERTY(EditAnywhere, Category = "Cover System")
|
||||||
|
bool bUseEyeHeight = true;
|
||||||
|
|
||||||
|
/** Minimalna wysokość przeszkody którą można określić osłoną */
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System",
|
||||||
|
meta = (EditCondition = "!UseEyeHeight"))
|
||||||
float CoverObstacleMinHeight = 75.0f;
|
float CoverObstacleMinHeight = 75.0f;
|
||||||
|
|
||||||
// Maksymalna wysokość przeszkody którą można określić osłoną
|
/** Maksymalna wysokość przeszkody którą można określić osłoną */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
||||||
float CoverObstacleMaxHeight = 125.0f;
|
float CoverObstacleMaxHeight = 125.0f;
|
||||||
|
|
||||||
// Promień wolnej przestrzeni przez którą można się wychylić
|
/** Promień wolnej przestrzeni przez którą można się wychylić */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
||||||
float CoverAimWindowRadius = 2.0f;
|
float CoverAimWindowRadius = 2.0f;
|
||||||
|
|
||||||
// Dystans od kamery po wychyleniu który musi być wolny by dało się wychylić
|
/** Dystans od kamery po wychyleniu który musi być wolny by dało się wychylić */
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cover System")
|
||||||
float CoverAimFreeDistance = 150.0f;
|
float CoverAimFreeDistance = 150.0f;
|
||||||
|
|
||||||
/** Określa na jaki procent "Stania" postać może się podnieść podczas celowania
|
/** Określa na jaki procent "Stania" postać może się podnieść podczas celowania
|
||||||
* zza osłony. 0 -> Nie podniesie się wogóle (jakby wychylanie się było wyłączone)
|
* zza osłony.<br>
|
||||||
|
* 0 -> Nie podniesie się wogóle (jakby wychylanie się było wyłączone) <br>
|
||||||
* 1 -> Postać jest w stanie się podnieść do pełnej wysokości, tak jakby normalnie stała
|
* 1 -> Postać jest w stanie się podnieść do pełnej wysokości, tak jakby normalnie stała
|
||||||
**/
|
**/
|
||||||
UPROPERTY(EditAnywhere,
|
UPROPERTY(EditAnywhere,
|
||||||
|
|
@ -232,7 +230,13 @@ private:
|
||||||
|
|
||||||
UShootingComponent* ShootingComponent;
|
UShootingComponent* ShootingComponent;
|
||||||
|
|
||||||
float CoverStandAlpha = 0.0f;
|
float CalculateCoverAimOffset();
|
||||||
|
void OnCoverTimer();
|
||||||
|
|
||||||
FTimerHandle CoverCheckTimer;
|
FTimerHandle CoverCheckTimer;
|
||||||
float MaxCoverAimHeight;
|
float MaxCoverAimHeight;
|
||||||
|
float CoverAimHeightOffset;
|
||||||
|
|
||||||
|
// temporary
|
||||||
|
bool bWasSliding = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user