From f2103a5bc16878c2e98583935a1193db33a19769 Mon Sep 17 00:00:00 2001 From: antoniukoff Date: Thu, 29 Feb 2024 15:26:28 -0500 Subject: [PATCH] Fixed the player sprinting issue when detaching head from body and respawning while holdingshift --- .../Core/Character/BP_Character.uasset | 4 +-- Content/Unbread/Maps/CoreLevelTest.umap | 4 +-- Source/unbread/Private/SCharacter.cpp | 27 ++++++++++++------- Source/unbread/Private/SDestructible.cpp | 1 - .../unbread/Private/SRanged_AIController.cpp | 2 +- Source/unbread/Private/SRespawnGameMode.cpp | 2 +- Source/unbread/Public/SCharacter.h | 4 +-- 7 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Content/Unbread/Core/Character/BP_Character.uasset b/Content/Unbread/Core/Character/BP_Character.uasset index 567d9920..59a870b5 100644 --- a/Content/Unbread/Core/Character/BP_Character.uasset +++ b/Content/Unbread/Core/Character/BP_Character.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e8404c57c5ab90772a804ea16fed1acc730a88e4e56b29720ed93d66110138d8 -size 277357 +oid sha256:1b97974dbce2d22d509c5d3efa2016d8f02beeb9ac93c683568e7bb6065494ef +size 276599 diff --git a/Content/Unbread/Maps/CoreLevelTest.umap b/Content/Unbread/Maps/CoreLevelTest.umap index b01b2e14..bf75c123 100644 --- a/Content/Unbread/Maps/CoreLevelTest.umap +++ b/Content/Unbread/Maps/CoreLevelTest.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:12a3a3256f8c54812b3bb109e99c1f9c019077605c68eb1370ce286b3d0998cc -size 556682 +oid sha256:ac599e7ef3ec9f66a3a91e2d18e0e4934c4633d1c35c62dafc8eb5301631fe78 +size 558026 diff --git a/Source/unbread/Private/SCharacter.cpp b/Source/unbread/Private/SCharacter.cpp index 144c96c8..cde2aed3 100644 --- a/Source/unbread/Private/SCharacter.cpp +++ b/Source/unbread/Private/SCharacter.cpp @@ -49,7 +49,6 @@ ASCharacter::ASCharacter() WalkSpeed = 0.5f; SprintSpeed = 1.0f; Speed = WalkSpeed; - bIsWalking = true; } // Called when the game starts or when spawned @@ -176,15 +175,21 @@ void ASCharacter::Sprint() return; } - bIsWalking = !bIsWalking; - if (bIsWalking) - { - Speed = WalkSpeed; - } - else + + Speed = SprintSpeed; + +} + +void ASCharacter::Walk() +{ + if(bIsHeadForm) { - Speed = SprintSpeed; + return; } + + + Speed = WalkSpeed; + } void ASCharacter::Landed(const FHitResult& Hit) @@ -265,9 +270,9 @@ void ASCharacter::ReformBody() NearestCrumbles->Destroy(); NearestCrumbles = nullptr; - bIsHeadForm = false; - + Speed = WalkSpeed; + DestroyBodyAndSpawnCrumbles(); AddActorWorldOffset(FVector(0.f, 0.f, 90.f)); @@ -305,6 +310,8 @@ void ASCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen // TEMPORARY EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Triggered, this, &ASCharacter::Sprint); + EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &ASCharacter::Walk); + // GAS EnhancedInputComponent->BindAction(PrimaryAttackAction, ETriggerEvent::Triggered, this, &ASCharacter::OnPrimaryAttack); diff --git a/Source/unbread/Private/SDestructible.cpp b/Source/unbread/Private/SDestructible.cpp index ccc1b4c0..b0c1f195 100644 --- a/Source/unbread/Private/SDestructible.cpp +++ b/Source/unbread/Private/SDestructible.cpp @@ -33,7 +33,6 @@ void ASDestructible::BeginPlay() } AbilitySystemComp->GetGameplayAttributeValueChangeDelegate(HealthAttributeSet->GetHealthAttribute()).AddUObject(this, &ASDestructible::OnHealthAttributeChanged); - } // Called every frame diff --git a/Source/unbread/Private/SRanged_AIController.cpp b/Source/unbread/Private/SRanged_AIController.cpp index 4b8e7732..ba3c3fef 100644 --- a/Source/unbread/Private/SRanged_AIController.cpp +++ b/Source/unbread/Private/SRanged_AIController.cpp @@ -144,7 +144,7 @@ void ASRanged_AIController::OnPerception(AActor* actor, FAIStimulus stimulus) } } -void ASRanged_AIController::SetDetectionLevel() +void ASRanged_AIController::SetDetectionLevel() { auto State = BBC->GetValueAsEnum("AIState"); diff --git a/Source/unbread/Private/SRespawnGameMode.cpp b/Source/unbread/Private/SRespawnGameMode.cpp index 0c072861..09a2d10f 100644 --- a/Source/unbread/Private/SRespawnGameMode.cpp +++ b/Source/unbread/Private/SRespawnGameMode.cpp @@ -56,7 +56,7 @@ void ASRespawnGameMode::SpawnPlayer() void ASRespawnGameMode::RespawnPlayer(AActor* Destroyed) { CurLives--; - + if (CheckLoss()) return; // spawn player with delay, or no delay if 0. diff --git a/Source/unbread/Public/SCharacter.h b/Source/unbread/Public/SCharacter.h index 16e13325..775696f9 100644 --- a/Source/unbread/Public/SCharacter.h +++ b/Source/unbread/Public/SCharacter.h @@ -122,10 +122,8 @@ class UNBREAD_API ASCharacter : public ACharacter, public IDynamicCameraInterfac UPROPERTY(EditAnywhere, Category = "Movement") float SprintSpeed; - UPROPERTY(EditAnywhere, Category = "Movement") - bool bIsWalking; - void Sprint(); + void Walk(); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Movement") float LerpSpeed = 0.6f;