diff --git a/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset b/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset index 3b8aa07..1d7e9d5 100644 Binary files a/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset and b/Content/Blueprints/Characters/Player/BP_ExoPlayerCharacter.uasset differ diff --git a/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset b/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset index 04d163e..b6733f8 100644 Binary files a/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset and b/Content/Blueprints/Player/Inputs/IMC_ExoMappingContext.uasset differ diff --git a/Source/Exo/Private/Player/ExoPlayerController.cpp b/Source/Exo/Private/Player/ExoPlayerController.cpp index f8822d0..f818b26 100644 --- a/Source/Exo/Private/Player/ExoPlayerController.cpp +++ b/Source/Exo/Private/Player/ExoPlayerController.cpp @@ -30,6 +30,9 @@ void AExoPlayerController::BeginPlay() InteractionComponent = PlayerCharacter->FindComponentByClass(); ShootingComponent = PlayerCharacter->FindComponentByClass(); + + // Ustawianie w komponencie poruszania prędkości zapisanej w characterze + PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed; } void AExoPlayerController::PlayerTick(float DeltaTime) @@ -48,8 +51,10 @@ void AExoPlayerController::SetupInputComponent() EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Triggered, this, &AExoPlayerController::Interact); EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerJump); EnhancedInputComponent->BindAction(DodgeAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerDodge); - EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerCrouch); - EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerSprint); + EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerStartCrouch); + EnhancedInputComponent->BindAction(CrouchAction, ETriggerEvent::Completed, this, &AExoPlayerController::PlayerStopCrouch); + EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerStartSprint); + EnhancedInputComponent->BindAction(SprintAction, ETriggerEvent::Completed, this, &AExoPlayerController::PlayerStopSprint); EnhancedInputComponent->BindAction(ShootAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerShoot); EnhancedInputComponent->BindAction(AimAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerAim); EnhancedInputComponent->BindAction(MeleAction, ETriggerEvent::Started, this, &AExoPlayerController::PlayerMeleAttack); @@ -90,7 +95,7 @@ void AExoPlayerController::Interact() void AExoPlayerController::PlayerJump() { - + PlayerCharacter->Jump(); } void AExoPlayerController::PlayerDodge() @@ -99,6 +104,8 @@ void AExoPlayerController::PlayerDodge() if (PlayerCharacter->GetCharacterMovement()->IsFalling()) return; + if (PlayerCharacter->GetCharacterMovement()->IsCrouching()) return; + if (!CanDodge) return; CanDodge = false; @@ -109,9 +116,9 @@ void AExoPlayerController::PlayerDodge() if (DodgeDirection.IsNearlyZero()) DodgeDirection = PlayerCharacter->GetActorForwardVector(); - PlayerCharacter->LaunchCharacter(DodgeDirection * DodgeForce, true, true); + PlayerCharacter->LaunchCharacter(DodgeDirection * PlayerCharacter->DodgeForce, true, true); - GetWorldTimerManager().SetTimer(DodgeCooldownTimer, this, &AExoPlayerController::ResetDodge, DodgeCooldown, false); + GetWorldTimerManager().SetTimer(DodgeCooldownTimer, this, &AExoPlayerController::ResetDodge, PlayerCharacter->DodgeCooldown, false); } void AExoPlayerController::ResetDodge() @@ -119,14 +126,28 @@ void AExoPlayerController::ResetDodge() CanDodge = true; } -void AExoPlayerController::PlayerCrouch() +void AExoPlayerController::PlayerStartCrouch() { - + PlayerCharacter->Crouch(); } -void AExoPlayerController::PlayerSprint() +void AExoPlayerController::PlayerStopCrouch() { + PlayerCharacter->UnCrouch(); +} +void AExoPlayerController::PlayerStartSprint() +{ + UE_LOG(LogTemp, Display, TEXT("Start sprint")); + + PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->SprintSpeed; +} + +void AExoPlayerController::PlayerStopSprint() +{ + UE_LOG(LogTemp, Display, TEXT("Stop sprint")); + + PlayerCharacter->GetCharacterMovement()->MaxWalkSpeed = PlayerCharacter->WalkSpeed; } void AExoPlayerController::PlayerShoot() diff --git a/Source/Exo/Public/Characters/ExoPlayerCharacter.h b/Source/Exo/Public/Characters/ExoPlayerCharacter.h index d694ee0..a4e0388 100644 --- a/Source/Exo/Public/Characters/ExoPlayerCharacter.h +++ b/Source/Exo/Public/Characters/ExoPlayerCharacter.h @@ -14,6 +14,18 @@ class EXO_API AExoPlayerCharacter : public AExoCharacterBase public: AExoPlayerCharacter(); + UPROPERTY(EditAnywhere, Category = "Dodge Properties") + float DodgeForce = 5000.f; + + UPROPERTY(EditAnywhere, Category = "Dodge Properties") + float DodgeCooldown = 2.f; + + UPROPERTY(EditAnywhere, Category = "Movement Properties") + float WalkSpeed = 600.0f; + + UPROPERTY(EditAnywhere, Category = "Movement Properties") + float SprintSpeed = 1500.0f; + protected: virtual void BeginPlay() override; diff --git a/Source/Exo/Public/Player/ExoPlayerController.h b/Source/Exo/Public/Player/ExoPlayerController.h index 93b3025..e2000e2 100644 --- a/Source/Exo/Public/Player/ExoPlayerController.h +++ b/Source/Exo/Public/Player/ExoPlayerController.h @@ -48,10 +48,16 @@ protected: void ResetDodge(); UFUNCTION(BlueprintCallable, Category = "Input") - void PlayerCrouch(); // LCtrl\C\X + void PlayerStartCrouch(); // LCtrl\C\X UFUNCTION(BlueprintCallable, Category = "Input") - void PlayerSprint(); // LShift(Hold) + void PlayerStopCrouch(); // LCtrl\C\X + + UFUNCTION(BlueprintCallable, Category = "Input") + void PlayerStartSprint(); // LShift(Hold) + + UFUNCTION(BlueprintCallable, Category = "Input") + void PlayerStopSprint(); UFUNCTION(BlueprintCallable, Category = "Input") void PlayerShoot(); // LPM @@ -96,12 +102,6 @@ protected: UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Dodge Properties") FTimerHandle DodgeCooldownTimer; - - UPROPERTY(EditAnywhere, Category = "Dodge Properties") - float DodgeForce = 5000.f; // Move to player if future for better modification - - UPROPERTY(EditAnywhere, Category = "Dodge Properties") - float DodgeCooldown = 2.f; // Move to player too. UPROPERTY(EditAnywhere, Category = "Dodge Properties") bool CanDodge = true;