Skip to content

Commit

Permalink
Merge pull request #142 from MashdorDev/Sprinting-fix
Browse files Browse the repository at this point in the history
Sprinting fix
  • Loading branch information
MashdorDev authored Feb 29, 2024
2 parents 4ec205a + 4596fc8 commit 4437004
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 @@ -62,7 +62,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 @@ -125,10 +125,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 4437004

Please sign in to comment.