Updated Interaction,TempCharacter.cpp
Removed the code from TempCharacter from last commit and created a new function Inside of Interaction that activates the TempCharacter.cpp InputEnabler()
This commit is contained in:
		
							parent
							
								
									d658c63627
								
							
						
					
					
						commit
						11e6393726
					
				| @ -9,6 +9,7 @@ | |||||||
| #include "GameFramework/Character.h" | #include "GameFramework/Character.h" | ||||||
| #include "Components/WidgetComponent.h" | #include "Components/WidgetComponent.h" | ||||||
| #include "Kismet/KismetMathLibrary.h" | #include "Kismet/KismetMathLibrary.h" | ||||||
|  | #include "the_twilight_abyss/PlayerTemp/TempCharacter.h" | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| // Sets default values
 | // Sets default values
 | ||||||
| @ -24,9 +25,8 @@ void AInteraction::BeginPlay() | |||||||
| 	Super::BeginPlay(); | 	Super::BeginPlay(); | ||||||
| 	 | 	 | ||||||
| 	//Character refs
 | 	//Character refs
 | ||||||
| 	TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); | 	TempCharacterRef = Cast<ATempCharacter>(GetWorld()->GetFirstPlayerController()->GetCharacter()); | ||||||
| 	MainCamera = Cast<UCameraComponent>(TempCharacter->FindComponentByClass<UCameraComponent>()); | 	MainCamera = Cast<UCameraComponent>(TempCharacterRef->FindComponentByClass<UCameraComponent>()); | ||||||
| 	 |  | ||||||
| 	//Item refs
 | 	//Item refs
 | ||||||
| 	 | 	 | ||||||
| 	TargetHealingLocation = HealingItem->GetActorLocation(); | 	TargetHealingLocation = HealingItem->GetActorLocation(); | ||||||
| @ -57,6 +57,7 @@ void AInteraction::BeginPlay() | |||||||
| 	BuyHealingTextWidget->AddToViewport(); | 	BuyHealingTextWidget->AddToViewport(); | ||||||
| 	//We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self
 | 	//We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self
 | ||||||
| 	BuyHealingProperty = BuyHealingTextWidget->GetClass()->FindPropertyByName("publicActor"); | 	BuyHealingProperty = BuyHealingTextWidget->GetClass()->FindPropertyByName("publicActor"); | ||||||
|  | 	 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // Called every frame
 | // Called every frame
 | ||||||
| @ -118,7 +119,7 @@ void AInteraction::RemoveWidget() | |||||||
| void AInteraction::CameraLeftMover() | void AInteraction::CameraLeftMover() | ||||||
| { | { | ||||||
| 	UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); | 	UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); | ||||||
| 	if (TempCharacter == nullptr || BuyHealingProperty == nullptr) | 	if (TempCharacterRef == nullptr || BuyHealingProperty == nullptr) | ||||||
| 	{ | 	{ | ||||||
| 		UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); | 		UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); | ||||||
| 		return; | 		return; | ||||||
| @ -148,7 +149,7 @@ void AInteraction::CameraLeftMover() | |||||||
| void AInteraction::CameraRightMover() | void AInteraction::CameraRightMover() | ||||||
| { | { | ||||||
| 	UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed")); | 	UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed")); | ||||||
| 	if (TempCharacter == nullptr || BuyBuffProperty == nullptr) | 	if (TempCharacterRef == nullptr || BuyBuffProperty == nullptr) | ||||||
| 	{ | 	{ | ||||||
| 		UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); | 		UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); | ||||||
| 		return; | 		return; | ||||||
| @ -181,15 +182,20 @@ void AInteraction::CancelPurchase() | |||||||
| 	BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden); | 	BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AInteraction::HealingPurchase() | void AInteraction::ExitScreen() | ||||||
| { | { | ||||||
| 	 | 	if (TempCharacterRef == nullptr) | ||||||
| } | 	{ | ||||||
| 
 | 		UE_LOG(LogTemp, Display, TEXT("TempCharacterRef in Interaction.cpp not found")); | ||||||
| void AInteraction::BuffPurchase() | 		return; | ||||||
| { | 	} | ||||||
| 	 | 	else | ||||||
|  | 	{ | ||||||
|  | 		TempCharacterRef->InputEnabler(); | ||||||
|  | 		ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); | ||||||
|  | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | |||||||
| @ -5,6 +5,7 @@ | |||||||
| #include "CoreMinimal.h" | #include "CoreMinimal.h" | ||||||
| #include "Camera/CameraComponent.h" | #include "Camera/CameraComponent.h" | ||||||
| #include "GameFramework/Actor.h" | #include "GameFramework/Actor.h" | ||||||
|  | #include "the_twilight_abyss/PlayerTemp/TempCharacter.h" | ||||||
| #include "Interaction.generated.h" | #include "Interaction.generated.h" | ||||||
| 
 | 
 | ||||||
| UCLASS() | UCLASS() | ||||||
| @ -70,9 +71,6 @@ public: | |||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera") | 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera") | ||||||
| 	UCameraComponent* MainCamera; | 	UCameraComponent* MainCamera; | ||||||
| 
 | 
 | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player") |  | ||||||
| 	ACharacter* TempCharacter; |  | ||||||
| 
 |  | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") | 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") | ||||||
| 	AActor* HealingItem; | 	AActor* HealingItem; | ||||||
| 
 | 
 | ||||||
| @ -83,10 +81,10 @@ public: | |||||||
| 	virtual void CancelPurchase(); | 	virtual void CancelPurchase(); | ||||||
| 
 | 
 | ||||||
| 	UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") | 	UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") | ||||||
| 	virtual void HealingPurchase(); | 	virtual void ExitScreen(); | ||||||
| 
 | 
 | ||||||
| 	UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") | 	UPROPERTY(EditAnywhere, Category = "Player") | ||||||
| 	virtual void BuffPurchase(); | 	ATempCharacter* TempCharacterRef; | ||||||
| 	 | 	 | ||||||
| private: | private: | ||||||
| 	 | 	 | ||||||
|  | |||||||
| @ -161,7 +161,6 @@ void ATempCharacter::InputEnabler() | |||||||
| 		ThisCamera->SetWorldLocation(OriginalCameraLocation); | 		ThisCamera->SetWorldLocation(OriginalCameraLocation); | ||||||
| 		ThisCamera->SetWorldRotation(OriginalCameraRotation); | 		ThisCamera->SetWorldRotation(OriginalCameraRotation); | ||||||
| 		ThisCamera->FieldOfView = OriginalCameraFOV; | 		ThisCamera->FieldOfView = OriginalCameraFOV; | ||||||
| 		ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); |  | ||||||
| 		//ulog the originalcameralocation value
 | 		//ulog the originalcameralocation value
 | ||||||
| 		UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); | 		UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); | ||||||
| 	} | 	} | ||||||
|  | |||||||
| @ -32,12 +32,9 @@ public: | |||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true")) | 	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true")) | ||||||
| 	class UInventoryComponent* Inventory; //Using the InventoryComponent class
 | 	class UInventoryComponent* Inventory; //Using the InventoryComponent class
 | ||||||
| 	 | 	 | ||||||
| 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ItemSelector") | 	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets") | ||||||
| 	UUserWidget* ItemSelectorWidget; | 	UUserWidget* ItemSelectorWidget; | ||||||
| 	 | 	 | ||||||
| 	UPROPERTY(EditAnywhere, Category = "Widgets") |  | ||||||
| 	TSubclassOf<UUserWidget> ItemSelector; |  | ||||||
| 	 |  | ||||||
| 	// Called to bind functionality to input
 | 	// Called to bind functionality to input
 | ||||||
| 	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; | 	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; | ||||||
| 	 | 	 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user