Updated TempCharacter
Created camera function which pans the camera to the object and raises FOV, Fixed multiple bugs to do with disabling input, Created BuyItem function which raises the TraceDistance temporarily so user can purchase at longer distances
This commit is contained in:
parent
77328aa887
commit
3752a24eab
@ -64,11 +64,12 @@ void ATempCharacter::KeyPressed()
|
||||
// Line trace logic
|
||||
void ATempCharacter::LineTraceLogic()
|
||||
{
|
||||
UE_LOG(LogTemp, Display, TEXT("LineTraceLogic firing"));
|
||||
float GlobalTrace = TraceDistance;
|
||||
FHitResult OutHit;
|
||||
FVector Start = GetActorLocation();
|
||||
FVector End = Start + GlobalTrace * GetActorForwardVector();
|
||||
|
||||
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||
FVector Start = ThisCamera->GetComponentLocation();
|
||||
FVector End = Start + GlobalTrace * ThisCamera->GetForwardVector();
|
||||
FCollisionQueryParams TraceParams;
|
||||
|
||||
TraceParams.AddIgnoredActor(this);
|
||||
@ -106,14 +107,11 @@ void ATempCharacter::LineTraceLogic()
|
||||
UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName());
|
||||
|
||||
// While loop to check bisDisabled var until it changes to true
|
||||
while (MyInteractable->bisDisabled == false)
|
||||
while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false)
|
||||
{
|
||||
if (MyInteractable->bisDisabled == true)
|
||||
if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true)
|
||||
{
|
||||
//I am creating a 5 second timer here that then executes the inputdisabler function
|
||||
FTimerHandle TimerHandle;
|
||||
FTimerDelegate TimerDelegate = FTimerDelegate::CreateUObject(this, &ATempCharacter::InputDisabler);
|
||||
GetWorld()->GetTimerManager().SetTimer(TimerHandle, TimerDelegate, 6.0f, false);
|
||||
InputDisabler();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -129,6 +127,19 @@ void ATempCharacter::InputDisabler()
|
||||
GetWorld()->GetFirstPlayerController()->bShowMouseCursor = true;
|
||||
GetWorld()->GetFirstPlayerController()->bEnableClickEvents = true;
|
||||
GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = true;
|
||||
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||
if (ThisCamera == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
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()
|
||||
@ -139,6 +150,20 @@ void ATempCharacter::InputEnabler()
|
||||
GetWorld()->GetFirstPlayerController()->bShowMouseCursor = false;
|
||||
GetWorld()->GetFirstPlayerController()->bEnableClickEvents = false;
|
||||
GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = false;
|
||||
ThisCamera = Cast<UCameraComponent>(this->FindComponentByClass<UCameraComponent>());
|
||||
if (ThisCamera == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
ThisCamera->SetWorldLocation(OriginalCameraLocation);
|
||||
ThisCamera->SetWorldRotation(OriginalCameraRotation);
|
||||
ThisCamera->FieldOfView = OriginalCameraFOV;
|
||||
|
||||
//ulog the originalcameralocation value
|
||||
UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
void ATempCharacter::UseItem(class UBaseItem* Item)
|
||||
@ -150,5 +175,12 @@ void ATempCharacter::UseItem(class UBaseItem* Item)
|
||||
}
|
||||
}
|
||||
|
||||
void ATempCharacter::BuyItem()
|
||||
{
|
||||
TraceDistance = 1000;
|
||||
LineTraceLogic();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -5,6 +5,9 @@
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "the_twilight_abyss/BaseItems/Items/BaseItem.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Evaluation/MovieSceneCameraAnimTemplate.h"
|
||||
#include "Kismet/KismetMathLibrary.h"
|
||||
#include "TempCharacter.generated.h"
|
||||
|
||||
UCLASS()
|
||||
@ -56,5 +59,16 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void InputEnabler();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera")
|
||||
UCameraComponent* ThisCamera;
|
||||
|
||||
FVector OriginalCameraLocation;
|
||||
|
||||
FRotator OriginalCameraRotation;
|
||||
|
||||
int OriginalCameraFOV;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category= "Items")
|
||||
void BuyItem();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user