Updated TempCharacter for Jump and Sneak
Added A sneak function and Jump function for the character
This commit is contained in:
parent
0cf4ace43a
commit
5b4da1f02e
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Combat_UI/CombatCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Blueprints/Player/BP_MyTempCharacter.uasset
(Stored with Git LFS)
BIN
Content/Blueprints/Player/BP_MyTempCharacter.uasset
(Stored with Git LFS)
Binary file not shown.
@ -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<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||
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<ACharacter>(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<ACharacter>(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)
|
||||
{
|
||||
|
@ -28,6 +28,9 @@ protected:
|
||||
UFUNCTION()
|
||||
void Sneak();
|
||||
|
||||
|
||||
UCapsuleComponent* PlayerCapsule;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
Loading…
Reference in New Issue
Block a user