diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index a1aecc3..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:75f1be8dcc2242cadbf525aee17e98a61c33a44d283b85f10073985ca70c642e +oid sha256:d41dd0f4c13a2823d7cda168b1109dfa219681d8f7fda30c966830823dc227a6 size 71310 diff --git a/Content/Blueprints/Player/BP_MyTempCharacter.uasset b/Content/Blueprints/Player/BP_MyTempCharacter.uasset index cf1a4a5..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:4f15d6bea7197b5335d686ea829286466b065c9e1329fcdb437a6c9aae018cc3 -size 65454 +oid sha256:9f65775451fb2105a879b7ceed94887ea520b41464c773052234285414565157 +size 54763 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index aa0414e..553ac9c 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -5,6 +5,8 @@ #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" @@ -17,6 +19,7 @@ ATempCharacter::ATempCharacter() Inventory->MaxItemSlots = 10; GoldBalance = GoldBalance; Health = Health; + this->GetCharacterMovement()->GetNavAgentPropertiesRef().bCanCrouch = true; } // Called when the game starts or when spawned @@ -25,6 +28,7 @@ void ATempCharacter::BeginPlay() Super::BeginPlay(); Health = 100; ThisCamera = Cast(this->FindComponentByClass()); + PlayerCapsule = GetCapsuleComponent(); } //Binds the input we made in the setup player component to the forward vector @@ -40,6 +44,15 @@ void ATempCharacter::RightMoveInput(float Axis) void ATempCharacter::Sneak() { + UE_LOG(LogTemp, Display, TEXT("Sneak activated")); + if (bIsCrouched) + { + UnCrouch(); + } + else + { + Crouch(); + } } @@ -60,6 +73,7 @@ void ATempCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputCompo 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); } @@ -149,14 +163,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; @@ -173,14 +190,18 @@ void ATempCharacter::InputDisabler() 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) { diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index ef4d667..c1f22e9 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -28,6 +28,9 @@ protected: UFUNCTION() void Sneak(); + + UCapsuleComponent* PlayerCapsule; + public: // Called every frame virtual void Tick(float DeltaTime) override;