Skip to content

Commit

Permalink
Fixed the player sprinting issue when detaching head from body and re…
Browse files Browse the repository at this point in the history
…spawning while holdingshift
  • Loading branch information
antoniukoff committed Feb 29, 2024
1 parent 7a4eea6 commit f2103a5
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Content/Unbread/Core/Character/BP_Character.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/Unbread/Maps/CoreLevelTest.umap
Git LFS file not shown
27 changes: 17 additions & 10 deletions Source/unbread/Private/SCharacter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ ASCharacter::ASCharacter()
WalkSpeed = 0.5f;
SprintSpeed = 1.0f;
Speed = WalkSpeed;
bIsWalking = true;
}

// Called when the game starts or when spawned
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -265,9 +270,9 @@ void ASCharacter::ReformBody()

NearestCrumbles->Destroy();
NearestCrumbles = nullptr;

bIsHeadForm = false;

Speed = WalkSpeed;

DestroyBodyAndSpawnCrumbles();

AddActorWorldOffset(FVector(0.f, 0.f, 90.f));
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion Source/unbread/Private/SDestructible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void ASDestructible::BeginPlay()
}

AbilitySystemComp->GetGameplayAttributeValueChangeDelegate(HealthAttributeSet->GetHealthAttribute()).AddUObject(this, &ASDestructible::OnHealthAttributeChanged);

}

// Called every frame
Expand Down
2 changes: 1 addition & 1 deletion Source/unbread/Private/SRanged_AIController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
2 changes: 1 addition & 1 deletion Source/unbread/Private/SRespawnGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions Source/unbread/Public/SCharacter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f2103a5

Please sign in to comment.