Merge branch 'player-movement' into dev
This commit is contained in:
commit
2d7091dee9
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/WBP_Crosshair.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Blueprints/WBP_Crosshair.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Sprint.uasset
(Stored with Git LFS)
Normal file
BIN
EndlessVendetta/Content/FirstPerson/Input/Actions/IA_Sprint.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/FirstPerson/Input/IMC_Default.uasset
(Stored with Git LFS)
Binary file not shown.
@ -69,14 +69,15 @@ void AEndlessVendettaCharacter::BeginPlay()
|
|||||||
}
|
}
|
||||||
|
|
||||||
InventoryComponent = Cast<UInventoryComponent>(GetWorld()->GetFirstPlayerController()->GetComponentByClass(UInventoryComponent::StaticClass()));
|
InventoryComponent = Cast<UInventoryComponent>(GetWorld()->GetFirstPlayerController()->GetComponentByClass(UInventoryComponent::StaticClass()));
|
||||||
|
WalkSpeed = CharacterMovement->MaxWalkSpeed;
|
||||||
|
OriginalWalkSpeed = CharacterMovement->MaxWalkSpeed;
|
||||||
|
CurrentStamina = MaxStamina;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::Tick(float DeltaTime)
|
void AEndlessVendettaCharacter::Tick(float DeltaTime)
|
||||||
{
|
{
|
||||||
Super::Tick(DeltaTime);
|
Super::Tick(DeltaTime);
|
||||||
|
|
||||||
WeaponPickUpSystem();
|
WeaponPickUpSystem();
|
||||||
|
|
||||||
MoveGroundSpeed = Cast<UMovementComponent>(GetComponentByClass(UMovementComponent::StaticClass()))->Velocity.Size();
|
MoveGroundSpeed = Cast<UMovementComponent>(GetComponentByClass(UMovementComponent::StaticClass()))->Velocity.Size();
|
||||||
|
|
||||||
if (MoveGroundSpeed > 0)
|
if (MoveGroundSpeed > 0)
|
||||||
@ -85,8 +86,40 @@ void AEndlessVendettaCharacter::Tick(float DeltaTime)
|
|||||||
}
|
}
|
||||||
else if (MoveGroundSpeed <= 0)
|
else if (MoveGroundSpeed <= 0)
|
||||||
{
|
{
|
||||||
|
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
|
||||||
bIsPlayerMoving = false;
|
bIsPlayerMoving = false;
|
||||||
}
|
}
|
||||||
|
if (bPressedJump)
|
||||||
|
{
|
||||||
|
if(CurrentStamina <= 0.0f)
|
||||||
|
{
|
||||||
|
CurrentStamina -= 20.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//PLAYER STAMINA HANDLING
|
||||||
|
if (MoveGroundSpeed > 0)
|
||||||
|
{
|
||||||
|
if (bIsPlayerSprinting)
|
||||||
|
{
|
||||||
|
CurrentStamina -= FMath::Clamp(StaminaDecreaseRate, 0.0f, 100.0f);
|
||||||
|
if (CurrentStamina <= 0.0f)
|
||||||
|
{
|
||||||
|
bIsPlayerSprinting = false;
|
||||||
|
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
|
||||||
|
CurrentStamina = 0.0f;
|
||||||
|
CharacterMovement->MaxWalkSpeed = OriginalWalkSpeed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!bIsPlayerSprinting)
|
||||||
|
{
|
||||||
|
if(CurrentStamina >= 100.0f)
|
||||||
|
{
|
||||||
|
CurrentStamina = 100.0f;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CurrentStamina += FMath::Clamp(StaminaRegenRate, 0.0f, 100.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::RegenHealth()
|
void AEndlessVendettaCharacter::RegenHealth()
|
||||||
@ -129,11 +162,13 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
|
|||||||
if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
|
if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
|
||||||
{
|
{
|
||||||
//Jumping
|
//Jumping
|
||||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::Jump);
|
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Jumping);
|
||||||
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
|
EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopJump);
|
||||||
|
|
||||||
//Moving
|
//Moving
|
||||||
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Move);
|
EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Move);
|
||||||
|
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Sprint);
|
||||||
|
EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &AEndlessVendettaCharacter::StopSprint);
|
||||||
|
|
||||||
//Looking
|
//Looking
|
||||||
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
|
EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AEndlessVendettaCharacter::Look);
|
||||||
@ -511,6 +546,54 @@ void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::Sprint()
|
||||||
|
{
|
||||||
|
bIsPlayerSprinting = true;
|
||||||
|
if (bIsPlayerSprinting)
|
||||||
|
{
|
||||||
|
if (MoveGroundSpeed > 0)
|
||||||
|
{
|
||||||
|
CharacterMovement->MaxWalkSpeed = SprintSpeed;
|
||||||
|
this->GetFirstPersonCameraComponent()->SetFieldOfView(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::StopSprint()
|
||||||
|
{
|
||||||
|
bIsPlayerSprinting = false;
|
||||||
|
if (!bIsPlayerSprinting)
|
||||||
|
{
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Player stopped sprinting"));
|
||||||
|
CharacterMovement->MaxWalkSpeed = OriginalWalkSpeed;
|
||||||
|
this->GetFirstPersonCameraComponent()->SetFieldOfView(90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::Jumping()
|
||||||
|
{
|
||||||
|
if (CurrentStamina > 10.0f)
|
||||||
|
{
|
||||||
|
bHasPlayerJumped = true;
|
||||||
|
if (bHasPlayerJumped)
|
||||||
|
{
|
||||||
|
Super::Jump();
|
||||||
|
if (!CharacterMovement->IsFalling())
|
||||||
|
{
|
||||||
|
CurrentStamina -= 10.0f;
|
||||||
|
}
|
||||||
|
bHasPlayerJumped = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AEndlessVendettaCharacter::StopJump()
|
||||||
|
{
|
||||||
|
Super::StopJumping();
|
||||||
|
UE_LOG(LogTemp, Display, TEXT("Player has stopped jumping"));
|
||||||
|
bHasPlayerJumped = false;
|
||||||
|
}
|
||||||
|
|
||||||
void AEndlessVendettaCharacter::Look(const FInputActionValue& Value)
|
void AEndlessVendettaCharacter::Look(const FInputActionValue& Value)
|
||||||
{
|
{
|
||||||
// input is a Vector2D
|
// input is a Vector2D
|
||||||
|
@ -73,6 +73,9 @@ class AEndlessVendettaCharacter : public ACharacter
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||||
UInputAction* InteractAction;
|
UInputAction* InteractAction;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
|
||||||
|
UInputAction* SprintAction;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AEndlessVendettaCharacter();
|
AEndlessVendettaCharacter();
|
||||||
|
|
||||||
@ -83,6 +86,23 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
||||||
float DefaultHealth = 100.0f;
|
float DefaultHealth = 100.0f;
|
||||||
|
|
||||||
|
//STAMINA AND SPRINT SPEED
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
||||||
|
float MaxStamina = 100;
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
||||||
|
float CurrentStamina;
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
||||||
|
float StaminaDecreaseRate = 0.2;
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
||||||
|
float StaminaRegenRate = 0.05;
|
||||||
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Stats")
|
||||||
|
float SprintSpeed = 900;
|
||||||
|
|
||||||
|
//Getting the charMovementComp
|
||||||
|
UCharacterMovementComponent* CharacterMovement = GetCharacterMovement();
|
||||||
|
float WalkSpeed;
|
||||||
|
float OriginalWalkSpeed;
|
||||||
|
|
||||||
AActor* PrimaryWeaponActor;
|
AActor* PrimaryWeaponActor;
|
||||||
AActor* SecondaryWeaponActor;
|
AActor* SecondaryWeaponActor;
|
||||||
bool bIsPrimaryWeaponCreated = false;
|
bool bIsPrimaryWeaponCreated = false;
|
||||||
@ -107,6 +127,9 @@ public:
|
|||||||
|
|
||||||
bool bIsPlayerMoving = false;
|
bool bIsPlayerMoving = false;
|
||||||
|
|
||||||
|
UPROPERTY(VisibleAnywhere)
|
||||||
|
bool bIsPlayerSprinting = false;
|
||||||
|
|
||||||
double MoveGroundSpeed;
|
double MoveGroundSpeed;
|
||||||
|
|
||||||
/** Look Input Action */
|
/** Look Input Action */
|
||||||
@ -149,6 +172,13 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
UFUNCTION(BlueprintCallable, Category = "Weapons")
|
||||||
void StopFire();
|
void StopFire();
|
||||||
|
|
||||||
|
void Sprint();
|
||||||
|
void StopSprint();
|
||||||
|
|
||||||
|
void Jumping();
|
||||||
|
void StopJump();
|
||||||
|
bool bHasPlayerJumped = false;
|
||||||
|
|
||||||
UArrowComponent* ScopedLocationArrow;
|
UArrowComponent* ScopedLocationArrow;
|
||||||
|
|
||||||
UPROPERTY(EditAnywhere, Category = "Dont Touch")
|
UPROPERTY(EditAnywhere, Category = "Dont Touch")
|
||||||
|
Loading…
Reference in New Issue
Block a user