diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index a87dbd8..8698439 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -82,6 +82,7 @@ DoubleClickTime=0.200000 +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) +ActionMappings=(ActionName="Interact",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=E) +ActionMappings=(ActionName="RightClick",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton) ++ActionMappings=(ActionName="Sneak",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftControl) +AxisMappings=(AxisName="Look Up / Down Gamepad",Scale=1.000000,Key=Gamepad_RightY) +AxisMappings=(AxisName="Look Up / Down Mouse",Scale=-1.000000,Key=MouseY) +AxisMappings=(AxisName="Move Forward / Backward",Scale=1.000000,Key=Gamepad_LeftY) diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index b1fb7b7..8d884e7 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:396a6ff81c0c1250e4a9251f6e9d027a09814199f3a07dc98ba8b087f35ce12b -size 72432 +oid sha256:d41dd0f4c13a2823d7cda168b1109dfa219681d8f7fda30c966830823dc227a6 +size 71310 diff --git a/Content/Blueprints/Player/BP_MyTempCharacter.uasset b/Content/Blueprints/Player/BP_MyTempCharacter.uasset index 68f202b..21e9727 100644 --- a/Content/Blueprints/Player/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/Player/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:df9e97f92efc6e557cb50693743a5db37bb9b97703afeccf8d1452b5886931ea -size 66442 +oid sha256:9f65775451fb2105a879b7ceed94887ea520b41464c773052234285414565157 +size 54763 diff --git a/Content/Levels/Top_layer_level.umap b/Content/Levels/Top_layer_level.umap index ad576cc..a338efc 100644 --- a/Content/Levels/Top_layer_level.umap +++ b/Content/Levels/Top_layer_level.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b9913f8136b9bf2c1f42801089b7071ad667f9467ee25d72ab588ae96d7543f2 -size 247266 +oid sha256:b12ca45d23f48747799c368c38e00f316adb025ea913272a4a36b69ec4b30fa3 +size 247139 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 1062d20..42a36fe 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -5,7 +5,10 @@ #include "Blueprint/UserWidget.h" #include "the_twilight_abyss/BaseItems/InventoryComponent.h" #include "the_twilight_abyss/BaseItems/Items/BaseItem.h" +#include "Components/CapsuleComponent.h" +#include "GameFramework/CharacterMovementComponent.h" #include "the_twilight_abyss/MerchantInteraction/Interaction.h" +#include // CONSTRUCTOR @@ -17,6 +20,8 @@ ATempCharacter::ATempCharacter() Inventory->MaxItemSlots = 10; GoldBalance = GoldBalance; Health = Health; + this->GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true; + } // Called when the game starts or when spawned @@ -25,6 +30,11 @@ void ATempCharacter::BeginPlay() Super::BeginPlay(); Health = 100; ThisCamera = Cast(this->FindComponentByClass()); + PlayerCapsule = GetCapsuleComponent(); + TArray AllActorsInScene; + + UGameplayStatics::GetAllActorsOfClass(GetWorld(), APostProcessVolume::StaticClass(), AllActorsInScene); + PostProcessVolume = Cast(AllActorsInScene[0]); } //Binds the input we made in the setup player component to the forward vector @@ -38,6 +48,22 @@ void ATempCharacter::RightMoveInput(float Axis) AddMovementInput(UKismetMathLibrary::GetRightVector(FRotator(0, GetControlRotation().Yaw, 0)) * Axis); } +void ATempCharacter::Sneak() +{ + UE_LOG(LogTemp, Display, TEXT("Sneak activated")); + if (bIsCrouched) + { + UnCrouch(); + PostProcessVolume->Settings.VignetteIntensity = 0.0f; + } + else + { + Crouch(); + PostProcessVolume->Settings.VignetteIntensity = 0.8f; + } + +} + // Called every frame void ATempCharacter::Tick(float DeltaTime) @@ -53,6 +79,9 @@ void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo PlayerInputComponent->BindAxis(TEXT("Move Right / Left"), this, &ATempCharacter::RightMoveInput); PlayerInputComponent->BindAxis(TEXT("Turn Right / Left Mouse"), this, &ATempCharacter::AddControllerYawInput); PlayerInputComponent->BindAxis(TEXT("Look Up / Down Mouse"), this, &ATempCharacter::AddControllerPitchInput); + PlayerInputComponent->BindAction(TEXT("Jump"), IE_Pressed, this, &ATempCharacter::Jump); + PlayerInputComponent->BindAction(TEXT("Sneak"), IE_Pressed, this, &ATempCharacter::Sneak); + PlayerInputComponent->BindAction(TEXT("Sneak"), IE_Released, this, &ATempCharacter::Sneak); PlayerInputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); } @@ -62,6 +91,8 @@ void ATempCharacter::KeyPressed() LineTraceLogic(); } + + // Line trace logic void ATempCharacter::LineTraceLogic() { @@ -140,14 +171,17 @@ void ATempCharacter::LineTraceLogic() void ATempCharacter::InputDisabler() { - UE_LOG(LogTemp, Display, TEXT("Disabling playermovement")); + //Disable Character Movement + if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) + { + PlayerCharacter->DisableInput(GetWorld()->GetFirstPlayerController()); + } + //Set to UI Mode Only + APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); + PlayerController->SetInputMode(FInputModeUIOnly()); + PlayerController->bShowMouseCursor = true; + disableTab = true; - //GetWorld()->GetFirstPlayerController()->InputComponent->RemoveActionBinding("Interact", IE_Pressed); - GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(true); - GetWorld()->GetFirstPlayerController()->SetIgnoreMoveInput(true); - GetWorld()->GetFirstPlayerController()->bShowMouseCursor = true; - GetWorld()->GetFirstPlayerController()->bEnableClickEvents = true; - GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = true; if (ThisCamera == nullptr) { return; @@ -157,21 +191,24 @@ void ATempCharacter::InputDisabler() OriginalCameraLocation = ThisCamera->GetComponentLocation(); OriginalCameraRotation = ThisCamera->GetComponentRotation(); OriginalCameraFOV = ThisCamera->FieldOfView; - //ulog the originalcameralocation value UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); } } void ATempCharacter::InputEnabler() { + //Enable Character Movement + if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) + { + PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController()); + } + //Reset UI Mode + APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); + PlayerController->SetInputMode(FInputModeGameOnly()); + PlayerController->bShowMouseCursor = false; + UE_LOG(LogTemp, Display, TEXT("Enabling Inputs")); disableTab = true; - GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(false); - GetWorld()->GetFirstPlayerController()->SetIgnoreMoveInput(false); - GetWorld()->GetFirstPlayerController()->bShowMouseCursor = false; - GetWorld()->GetFirstPlayerController()->bEnableClickEvents = false; - GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = false; - //GetWorld()->GetFirstPlayerController()->InputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); TraceDistance = 300; if (ThisCamera == nullptr) { @@ -182,7 +219,6 @@ void ATempCharacter::InputEnabler() ThisCamera->SetWorldLocation(OriginalCameraLocation); ThisCamera->SetWorldRotation(OriginalCameraRotation); ThisCamera->FieldOfView = OriginalCameraFOV; - //ulog the originalcameralocation value UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); } } @@ -192,7 +228,7 @@ void ATempCharacter::UseItem(class UBaseItem* Item) if(Item) { Item->Use(this); - Item->OnUse(this); //Blueprint Version + Item->OnUse(this); //OnUse is a Blueprint Version } } diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 510587b..f162b7f 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -7,6 +7,7 @@ #include "the_twilight_abyss/BaseItems/Items/BaseItem.h" #include "Camera/CameraComponent.h" #include "Kismet/KismetMathLibrary.h" +#include "Engine/PostProcessVolume.h" #include "TempCharacter.generated.h" UCLASS() @@ -25,6 +26,12 @@ protected: void ForwardInput(float Axis); void RightMoveInput(float Axis); + UFUNCTION() + void Sneak(); + + + UCapsuleComponent* PlayerCapsule; + public: // Called every frame virtual void Tick(float DeltaTime) override; @@ -80,5 +87,6 @@ public: UPROPERTY(BlueprintReadWrite) bool disableTab = false; - + + APostProcessVolume* PostProcessVolume; };