ab2d2118dd
Added base functionality for both functions to make camera move
86 lines
1.9 KiB
C++
86 lines
1.9 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "Interaction.h"
|
|
|
|
#include "Chaos/BoundingVolumeUtilities.h"
|
|
#include "Components/Button.h"
|
|
#include "Components/WidgetComponent.h"
|
|
|
|
|
|
|
|
// Sets default values
|
|
AInteraction::AInteraction()
|
|
{
|
|
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
|
PrimaryActorTick.bCanEverTick = true;
|
|
}
|
|
|
|
// Called when the game starts or when spawned
|
|
void AInteraction::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
|
|
}
|
|
|
|
// Called every frame
|
|
void AInteraction::Tick(float DeltaTime)
|
|
{
|
|
Super::Tick(DeltaTime);
|
|
|
|
}
|
|
|
|
void AInteraction::OnInteract()
|
|
{
|
|
ShopDialogWidget = CreateWidget<UUserWidget>(GetWorld(), ShopDialog);
|
|
if (ShopDialogWidget == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
ShopDialogWidget->AddToViewport(0);
|
|
}
|
|
//handles the widget disappearing from the viewport
|
|
FTimerHandle WidgetTimer;
|
|
GetWorldTimerManager().SetTimer(WidgetTimer, this, &AInteraction::RemoveWidget, WaitTimer, false);
|
|
|
|
}
|
|
|
|
void AInteraction::RemoveWidget()
|
|
{
|
|
bisDisabled = true;
|
|
ShopDialogWidget->RemoveFromViewport();
|
|
UE_LOG(LogTemp, Display, TEXT("setting isDisabled to true"));
|
|
ItemSelectorWidget = CreateWidget<UUserWidget>(GetWorld(), ItemSelector);
|
|
UProperty* Property = ItemSelectorWidget->GetClass()->FindPropertyByName("publicActor");
|
|
if (Property == nullptr)
|
|
{
|
|
UE_LOG(LogTemp, Error, TEXT("Property not found"));
|
|
}
|
|
else
|
|
{
|
|
FObjectPropertyBase* ObjectProperty = static_cast<FObjectPropertyBase*>(Property);
|
|
ObjectProperty->SetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr<void>(ItemSelectorWidget), this);
|
|
}
|
|
if (ItemSelectorWidget == nullptr)
|
|
{
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
ItemSelectorWidget->AddToViewport(0);
|
|
bisDisabled = false;
|
|
}
|
|
}
|
|
|
|
void AInteraction::CameraLeftMover()
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed"));
|
|
}
|
|
|
|
void AInteraction::CameraRightMover()
|
|
{
|
|
UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed"));
|
|
}
|