More refactors, remove universal camera, tweak build script
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include "ProjectEleri/GameObjects/BookActor.h"
|
||||
#include "UI/TradeWidget.h"
|
||||
#include "ProjectEleri/Public/UI/SelectionManager.h"
|
||||
#include "RTSCameraPlugin/Public/UniversalCamera.h"
|
||||
#include "ProjectEleri/DialogueSystem/DialogueWidget.h"
|
||||
|
||||
AEleriPlayerController::AEleriPlayerController(const FObjectInitializer &ObjectInitializer)
|
||||
@@ -342,8 +341,8 @@ void AEleriPlayerController::OnMove(const FInputActionValue &Value)
|
||||
// FVector ForwardFacing = UKismetMathLibrary::GetForwardVector(bFlying? PlayerCameraManager->GetCameraRotation() : CharRotForward);
|
||||
float AppliedMovementVelocity = 1.f; // MovementVelocity * (bFlying? 0.5f : 1.f);
|
||||
|
||||
FVector ForwardVec = AUniversalCamera::GetAlternativeForwardVector(PlayerCharacter->GetPlayerCamera()->DesiredRotation);
|
||||
FVector RightVec = AUniversalCamera::GetAlternativeRightVector(PlayerCharacter->GetPlayerCamera()->DesiredRotation);
|
||||
FVector ForwardVec = PlayerCharacter->GetPlayerCamera()->GetForwardVector();
|
||||
FVector RightVec = PlayerCharacter->GetPlayerCamera()->GetRightVector();
|
||||
|
||||
PlayerCharacter->AddMovementInput(ForwardVec, MovementDirection.Y * AppliedMovementVelocity);
|
||||
PlayerCharacter->AddMovementInput(RightVec, MovementDirection.X * AppliedMovementVelocity);
|
||||
@@ -409,8 +408,8 @@ void AEleriPlayerController::OnLook(const FInputActionValue &Value)
|
||||
|
||||
if (PlayerCharacter != nullptr)
|
||||
{
|
||||
PlayerCharacter->GetPlayerCamera()->RotateYaw(AnalogueValue.X);
|
||||
PlayerCharacter->GetPlayerCamera()->RotatePitch(AnalogueValue.Y);
|
||||
AddYawInput(AnalogueValue.X);
|
||||
AddPitchInput(AnalogueValue.Y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include "ProjectEleri/GameObjects/BookActor.h"
|
||||
#include "TimeOfDayManager.h"
|
||||
#include "Components/PostProcessComponent.h"
|
||||
#include "Components/SceneCaptureComponent2D.h"
|
||||
#include "Engine/TextureRenderTarget2D.h"
|
||||
#include "GameFramework/PawnMovementComponent.h"
|
||||
#include "ProjectEleri/GameObjects/BenchmarkActor.h"
|
||||
#include "ProjectEleri/System/MainBlueprintFunctionLibrary.h"
|
||||
@@ -22,11 +20,8 @@
|
||||
#include "ProjectEleri/GameObjects/BookActor.h"
|
||||
#include "ProjectEleri/GameObjects/BroomActor.h"
|
||||
#include "Components/CapsuleComponent.h"
|
||||
#include "DisplayDebugHelpers.h"
|
||||
#include "Components/StatForgeComponent.h"
|
||||
#include "Engine/Canvas.h"
|
||||
#include "RTSCameraPlugin/Public/UniversalCamera.h"
|
||||
#include "RTSCameraPlugin/Public/AsyncNode.h"
|
||||
#include "GameFramework/SpringArmComponent.h"
|
||||
|
||||
|
||||
#if WITH_EDITOR
|
||||
@@ -78,10 +73,10 @@ void AMyCharacter::BeginPlay()
|
||||
InteractableOverlapMesh->OnComponentEndOverlap.AddDynamic(this, &AMyCharacter::OnLeftInteractableObject);
|
||||
}
|
||||
|
||||
CameraRef = GetWorld()->SpawnActor<AUniversalCamera>(CameraClass, GetActorTransform());
|
||||
//CameraRef->AttachToActor(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
|
||||
PlayerController->SetViewTarget(CameraRef);
|
||||
CameraStartFollowPlayer();
|
||||
CameraRef = GetComponentByClass<UCameraComponent>();
|
||||
SpringArmRef = GetComponentByClass<USpringArmComponent>();
|
||||
PlayerController->SetViewTarget(this);
|
||||
SpringArmRef->TargetArmLength = DefaultZoom;
|
||||
|
||||
TSet<UActorComponent*> CameraComponents = GetComponents();
|
||||
for (auto Comp : CameraComponents)
|
||||
@@ -100,7 +95,7 @@ void AMyCharacter::BeginPlay()
|
||||
BookTransform.SetRotation(FRotator(0,0,0).Quaternion());
|
||||
BookTransform.SetScale3D(FVector::OneVector);
|
||||
BookActor = GetWorld()->SpawnActor<ABookActor>(BookActorClass, BookTransform);
|
||||
BookActor->AttachToActor(CameraRef.Get(), FAttachmentTransformRules::KeepRelativeTransform);
|
||||
BookActor->AttachToComponent(CameraRef.Get(), FAttachmentTransformRules::KeepRelativeTransform);
|
||||
BookActor->SetActorRelativeLocation(FVector(300,0,0));
|
||||
BookActor->SetActorRelativeRotation(FRotator(0,90,0).Quaternion());
|
||||
|
||||
@@ -144,10 +139,10 @@ void AMyCharacter::Tick(float DeltaTime)
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
if (CurrentZoomTimer > 0.f) {
|
||||
float ZoomDelta = (NextZoomOffsetTarget * DeltaTime) / ZoomTime;
|
||||
CameraRef->ZoomIn(ZoomDelta, 0.01f);
|
||||
const float ZoomDelta = (NextZoomOffsetTarget * DeltaTime) / ZoomTime;
|
||||
SpringArmRef->TargetArmLength += ZoomDelta;
|
||||
CurrentZoomTimer -= DeltaTime;
|
||||
//UE_LOG(LogTemp, Warning, TEXT("Zooming in: ZoomDelta:%f"), ZoomDelta);
|
||||
UE_LOG(LogTemp, Warning, TEXT("Zooming in: ZoomDelta:%f"), ZoomDelta);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,20 +168,6 @@ FVector AMyCharacter::GetCameraWorldPosition() {
|
||||
return CameraLocation;
|
||||
}
|
||||
|
||||
FVector AMyCharacter::GetCameraForwardVector() {
|
||||
FVector CameraLocation;
|
||||
FRotator CameraRotation;
|
||||
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(CameraLocation, CameraRotation);
|
||||
return CameraRotation.Quaternion().GetForwardVector();
|
||||
}
|
||||
|
||||
FRotator AMyCharacter::GetCameraRotation() {
|
||||
FVector CameraLocation;
|
||||
FRotator CameraRotation;
|
||||
GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(CameraLocation, CameraRotation);
|
||||
return CameraRotation;
|
||||
}
|
||||
|
||||
void AMyCharacter::ToggleBook(bool bOpen)
|
||||
{
|
||||
if (!IsValid(BookActor)) return;
|
||||
@@ -221,7 +202,6 @@ void AMyCharacter::OnHarvestSeed_Implementation(class UItem* HarvestedItem)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void AMyCharacter::ZoomCamera(float CameraZoomAmount, float Time)
|
||||
{
|
||||
CurrentZoomTimer = Time;
|
||||
@@ -230,33 +210,12 @@ void AMyCharacter::ZoomCamera(float CameraZoomAmount, float Time)
|
||||
}
|
||||
|
||||
void AMyCharacter::ZoomBack(float Time) {
|
||||
ZoomCamera(-(DefaultCameraZoom - CameraRef->DesiredZoom), Time);
|
||||
ZoomCamera(SpringArmRef->TargetArmLength - DefaultZoom, Time);
|
||||
}
|
||||
|
||||
void AMyCharacter::ReturnCameraToPlayer() {
|
||||
FTargetVector UseActorLocation;
|
||||
UseActorLocation.TargetMod = TargetMod_Actor;
|
||||
FTargetFloat UseActorValue;
|
||||
UseActorValue.TargetMod = TargetMod_Actor;
|
||||
FTargetFloat UseCustomValue;
|
||||
UseCustomValue.TargetMod = TargetMod_CustomValue;
|
||||
UseCustomValue.FloatValue = DefaultCameraZoom;
|
||||
FTravelSpeedSettings UseDuration;
|
||||
UseDuration.UseSpeed = false;
|
||||
UseDuration.Duration = 0.2f;
|
||||
FTargetSettings UseActor;
|
||||
UseActor.Actor = this;
|
||||
|
||||
FTargetFloat UsePitchValue;
|
||||
UsePitchValue.TargetMod = TargetMod_CustomValue;
|
||||
UsePitchValue.FloatValue = -40.f;
|
||||
if (UAsyncNode* Node = UAsyncNode::CameraTravel(CameraRef, UseActor, UseActorLocation, FOffsetSettings(), UseActorValue, UsePitchValue, UseActorValue, UseCustomValue, nullptr, UseDuration, false, true, true)) {
|
||||
Node->OnReachedDestination.AddUniqueDynamic(this, &AMyCharacter::CameraStartFollowPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
void AMyCharacter::CameraStartFollowPlayer() {
|
||||
CameraRef->FollowTarget(AUniversalCamera::UseActor(this), FConstrainVector2(), FBoolRotation());
|
||||
SpringArmRef->TargetArmLength = DefaultZoom;
|
||||
PlayerController->SetViewTargetWithBlend(this, 0.5f);
|
||||
}
|
||||
|
||||
void AMyCharacter::SetSaveableTagData(FGameplayTag Tag, int32 NewValue) {
|
||||
@@ -369,7 +328,7 @@ void AMyCharacter::BeginWatering()
|
||||
{
|
||||
const FAttachmentTransformRules AttachRules = FAttachmentTransformRules(EAttachmentRule::KeepRelative, false);
|
||||
WaterBallSpawned->AttachToComponent(Cast<USceneComponent>(this->GetComponentByClass(USceneComponent::StaticClass())), AttachRules);
|
||||
WaterBallSpawned->SetActorLocation(GetActorLocation() + (CameraRef->GetActorForwardVector() * 100.f) + (GetActorRightVector() * 200.f));
|
||||
WaterBallSpawned->SetActorLocation(GetActorLocation() + (CameraRef->GetForwardVector() * 100.f) + (GetActorRightVector() * 200.f));
|
||||
WaterBallSpawned->BeginAnimating();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ public class ProjectEleri : ModuleRules
|
||||
"Json",
|
||||
"JsonUtilities",
|
||||
"GameplayTasks",
|
||||
"UniversalCameraPlugin",
|
||||
"StateTreeModule",
|
||||
"GameplayStateTreeModule",
|
||||
"DirectiveUtilitiesRuntime",
|
||||
|
||||
@@ -11,8 +11,6 @@
|
||||
#include "../System/Subsystem/ObjectPersistenceSubsystem.h"
|
||||
#include "Interface/SaveableObjectInterface.h"
|
||||
#include "ProjectEleri/GameEventSystem/GameEventSubsystem.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "GameplayEffect.h"
|
||||
#include "Data/GameplayStatEffect.h"
|
||||
#include "Data/StatForgeDefs.h"
|
||||
#include "ProjectEleri/System/TimeOfDayStruct.h"
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
#include "GlobalEnums.h"
|
||||
#include "Camera/CameraComponent.h"
|
||||
#include "Delegates/Delegate.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "ProjectEleri/Public/Interface/SaveableObjectInterface.h"
|
||||
|
||||
#include "MyCharacter.generated.h"
|
||||
|
||||
class USpringArmComponent;
|
||||
class UStatForgeComponent;
|
||||
class AEleriPlayerController;
|
||||
class AWaterBall;
|
||||
@@ -75,14 +75,16 @@ protected:
|
||||
UStatForgeComponent* StatForgeComponent;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<AUniversalCamera> CameraRef;
|
||||
TObjectPtr<UCameraComponent> CameraRef;
|
||||
UPROPERTY()
|
||||
TObjectPtr<USpringArmComponent> SpringArmRef;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess))
|
||||
float DefaultZoom = 2000.f;
|
||||
|
||||
float CurrentZoomTimer = 0.f;
|
||||
float ZoomTime = 0.f;
|
||||
float NextZoomOffsetTarget = 0.f;
|
||||
float DefaultZoom = 0.f;
|
||||
UFUNCTION()
|
||||
void CameraStartFollowPlayer();
|
||||
|
||||
|
||||
//----- ISaveableObjectInterface -----
|
||||
// This is so actors can have custom data and we don't need to create new classes for it
|
||||
@@ -116,9 +118,6 @@ public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSubclassOf<AWaterBall> WaterBallClass;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
||||
TSubclassOf<AUniversalCamera> CameraClass;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
bool bIsWatering;
|
||||
UPROPERTY(BlueprintReadOnly, EditAnywhere)
|
||||
@@ -148,24 +147,15 @@ public:
|
||||
UFUNCTION(BlueprintCallable, Category = "Camera Controll")
|
||||
void ReturnCameraToPlayer();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
float DefaultCameraZoom = 0.f;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void SetNewCameraPitches(float NewMinPitch, float NewMaxPitch);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
FORCEINLINE AUniversalCamera* GetPlayerCamera() { return CameraRef; }
|
||||
FORCEINLINE UCameraComponent* GetPlayerCamera() { return CameraRef; }
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
FVector GetCameraWorldPosition();
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
FVector GetCameraForwardVector();
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure)
|
||||
FRotator GetCameraRotation();
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
void ToggleBook(bool bOpen);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user