diff --git a/Source/lonese/CameraPawn.cpp b/Source/lonese/CameraPawn.cpp new file mode 100644 index 0000000..1326103 --- /dev/null +++ b/Source/lonese/CameraPawn.cpp @@ -0,0 +1,55 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "CameraPawn.h" + +#include "GameFramework/SpringArmComponent.h" +#include "Camera/CameraComponent.h" + +void ACameraPawn::CameraZoom(const FInputActionValue& Value) +{ +} + +void ACameraPawn::CameraRotate(const FInputActionValue& Value) +{ +} + +void ACameraPawn::CameraMove(const FInputActionValue& Value) +{ +} + +// Sets default values +ACameraPawn::ACameraPawn() +{ + // Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + + SpringArmComponent = CreateDefaultSubobject(TEXT("SpringArmComponent")); + SpringArmComponent->SetupAttachment(RootComponent); + SpringArmComponent->TargetArmLength = 300.f; + SpringArmComponent->bUsePawnControlRotation = true; + CameraComponent = CreateDefaultSubobject(TEXT("CameraComponent")); + CameraComponent->SetupAttachment(SpringArmComponent, USpringArmComponent::SocketName); +} + +// Called when the game starts or when spawned +void ACameraPawn::BeginPlay() +{ + Super::BeginPlay(); + +} + +// Called every frame +void ACameraPawn::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); + +} + +// Called to bind functionality to input +void ACameraPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) +{ + Super::SetupPlayerInputComponent(PlayerInputComponent); + +} + diff --git a/Source/lonese/CameraPawn.h b/Source/lonese/CameraPawn.h new file mode 100644 index 0000000..330d854 --- /dev/null +++ b/Source/lonese/CameraPawn.h @@ -0,0 +1,41 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Pawn.h" +#include "CameraPawn.generated.h" + +UCLASS() +class LONESE_API ACameraPawn : public APawn +{ + GENERATED_BODY() + +public: + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera") + class USpringArmComponent* SpringArmComponent; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera") + class UCameraComponent* CameraComponent; + + UFUNCTION(BlueprintCallable, Category = "Camera") + void CameraZoom(const FInputActionValue& Value); + UFUNCTION(BlueprintCallable, Category = "Camera") + void CameraRotate(const FInputActionValue& Value); + UFUNCTION(BlueprintCallable, Category = "Camera") + void CameraMove(const FInputActionValue& Value); + + // Sets default values for this pawn's properties + ACameraPawn(); + // Called every frame + virtual void Tick(float DeltaTime) override; + + // Called to bind functionality to input + virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +private: + +}; diff --git a/Source/lonese/MyCharacter.cpp b/Source/lonese/MyCharacter.cpp index 8edecbe..422cf9a 100644 --- a/Source/lonese/MyCharacter.cpp +++ b/Source/lonese/MyCharacter.cpp @@ -7,6 +7,8 @@ #include "EnhancedInputComponent.h" #include "GameFramework/CharacterMovementComponent.h" +#include "CameraPawn.h" + void AMyCharacter::Move(const FInputActionValue& Value) { auto f2d = Value.Get(); diff --git a/Source/lonese/MyCharacter.h b/Source/lonese/MyCharacter.h index 20b0816..d9799a5 100644 --- a/Source/lonese/MyCharacter.h +++ b/Source/lonese/MyCharacter.h @@ -21,6 +21,9 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input") class UInputAction* CrouchAction; + UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Camera") + class ACameraPawn* CameraActor; + UFUNCTION(BlueprintCallable, Category = "Move") void Move(const FInputActionValue& Value); UFUNCTION(BlueprintCallable, Category = "Move") diff --git a/lonese.uproject b/lonese.uproject index 3776ce6..7e618d4 100644 --- a/lonese.uproject +++ b/lonese.uproject @@ -1,34 +1,33 @@ { - "FileVersion": 3, - "EngineAssociation": "5.7", - "Category": "", - "Description": "", - "Modules": [ - { - "Name": "lonese", - "Type": "Runtime", - "LoadingPhase": "Default" - } - ], - "Plugins": [ - { - "Name": "ModelingToolsEditorMode", - "Enabled": true - }, - { - "Name": "Text3D", - "Enabled": true - }, - { - "Name": "VisualStudioTools", - "Enabled": true, - "SupportedTargetPlatforms": [ - "Win64" - ] - } - ], - "TargetPlatforms": [], - "AdditionalRootDirectories": [], - "AdditionalPluginDirectories": [], - "EpicSampleNameHash": "" + "FileVersion": 3, + "EngineAssociation": "5.7", + "Category": "", + "Description": "", + "Modules": [ + { + "Name": "lonese", + "Type": "Runtime", + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] + } + ], + "Plugins": [ + { + "Name": "ModelingToolsEditorMode", + "Enabled": true + }, + { + "Name": "Text3D", + "Enabled": true + }, + { + "Name": "VisualStudioTools", + "Enabled": true, + "SupportedTargetPlatforms": [ + "Win64" + ] + } + ] } \ No newline at end of file