๋ธ
์ ํํ์ง๋ฌธ ใ
ใ
ํจ ์ธ๋ฆฌ์ผ 5.3.2ย ์ฐ๊ณ ์์ ํ๋ก์ ํธ ๊ธฐ๋ฐ์ผ๋ก ๋ฐฐ์ฐ๋ ์ธ๋ฆฌ์ผ ์์ง 5 ๊ฒ์ ๊ฐ๋ฐ ๋ฐ๋ผํ๊ณ ์๋๋ฐ
๋์ ํ ์๋ผ์ ๊น์ ์ฌ๋ผ์์๋ ์์ค์ฝ๋ ๋ณต๋ถ ํ๋๋ฐ๋ ๋๊ฐ์ ๋ถ๋ถ์์ ๋ ธ๊ฐ๋ค ๊ณต์ฌํ ๋ง๋ฅ ํตํ๊ธ์ง ํ์ํ์ด ์ฌ๋ผ์ง์ง๋ฅผ ์์
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyThirdPersonChar.h"
#include "Components/CapsuleComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "InputMappingContext.h"
#include "InputAction.h"ย
#include "Kismet/KismetMathLibrary.h"
#include "GameFramework/Controller.h"
// Sets default values
AMyThirdPersonChar::AMyThirdPersonChar()
{
// Set this character to call Tick() every frame.ย You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
// Set size for collision capsule
GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);
// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = true;
// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 300.0f;
CameraBoom->bUsePawnControlRotation = true;
// Create a follow camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);
FollowCamera->bUsePawnControlRotation = false;
}
void AMyThirdPersonChar::BeginPlay()
{
Super::BeginPlay();
}
void AMyThirdPersonChar::Move(const FInputActionValue& Value)
{
FVector2D InputValue = Value.Get<FVector2D>();
if (Controller != nullptr && (InputValue.X != 0.0f || InputValue.Y != 0.0f))
{
const FRotator YawRotation(0, Controller->GetControlRotation().Yaw, 0);
if (InputValue.X != 0.0f)
{
// get right vectorย
const FVector RightDirection = UKismetMathLibrary::GetRightVector(YawRotation);
// add movement in that direction
AddMovementInput(RightDirection, InputValue.X);
}
if (InputValue.Y != 0.0f)
{
// get forward vector
const FVector ForwardDirection = YawRotation.Vector();
AddMovementInput(ForwardDirection, InputValue.Y);
}
}
}
void AMyThirdPersonChar::Look(const FInputActionValue& Value)
{
FVector2D InputValue = Value.Get<FVector2D>();
if (InputValue.X != 0.0f)
{
AddControllerYawInput(InputValue.X);
}
if (InputValue.Y != 0.0f)
{
AddControllerPitchInput(InputValue.Y);
}
}
void AMyThirdPersonChar::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AMyThirdPersonChar::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
UEnhancedInputComponent* EnhancedPlayerInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent);
if (EnhancedPlayerInputComponent != nullptr)
{
APlayerController* PlayerController = Cast<APlayerController>(GetController());
if (PlayerController != nullptr)
{
UEnhancedInputLocalPlayerSubsystem* EnhancedSubsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer());
if (EnhancedSubsystem != nullptr)
{
EnhancedSubsystem->AddMappingContext(IC_Character, 1);
}
}
EnhancedPlayerInputComponent->BindAction(IA_Move, ETriggerEvent::Triggered, this, &AMyThirdPersonChar::Move);
EnhancedPlayerInputComponent->BindAction(IA_Jump, ETriggerEvent::Started, this, &ACharacter::Jump);
EnhancedPlayerInputComponent->BindAction(IA_Jump, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
EnhancedPlayerInputComponent->BindAction(IA_Look, ETriggerEvent::Triggered, this, &AMyThirdPersonChar::Look);
}
}
c++ ์ ๋ฌธ
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/Character.h"
#include "InputActionValue.h"
#include "MyThirdPersonChar.generated.h"
UCLASS()
class MYTHIRDPERSON_API AMyThirdPersonChar : public ACharacter
{
GENERATED_BODY()
// Camera boom positioning the camera behind the character
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = MyTPS_Cam, meta = (AllowPrivateAccess = "true"))
USpringArmComponent* CameraBoom;
// Follow camera
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = MyTPS_Cam, meta = (AllowPrivateAccess = "true"))
UCameraComponent* FollowCamera;
public:
// Sets default values for this character's properties
AMyThirdPersonChar();
UPROPERTY(EditAnywhere, Category = Input)
class UInputMappingContext* IC_Character;
UPROPERTY(EditAnywhere, Category = Input)
class UInputAction* IA_Move;
UPROPERTY(EditAnywhere, Category = Input)
class UInputAction* IA_Jump;
UPROPERTY(EditAnywhere, Category = Input)
class UInputAction* IA_Look;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
void Move(const FInputActionValue& Value);
void Look(const FInputActionValue& Value);
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
// Called to bind functionality to input
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
};
ํค๋ํ์ผ ์ ๋ฌธ
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class MyThirdPerson : ModuleRules
{
ย ย public MyThirdPerson(ReadOnlyTargetRules Target) : base(Target)
ย ย {
ย ย ย ย PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
ย ย ย ย PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" });
ย ย ย ย PrivateDependencyModuleNames.AddRange(new string[] { });
ย ย ย ย // Uncomment if you are using Slate UI
ย ย ย ย // PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
ย ย ย ย // Uncomment if you are using online features
ย ย ย ย // PrivateDependencyModuleNames.Add("OnlineSubsystem");
ย ย ย ย // To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
ย ย }
}
c#ํ์ผ ์ ๋ฌธ
์ง์ง ์ฝ๋ ๋ณต๋ถ์ ์์ ๊น์ง ๋ค์ด ๋ฐ์ ์ฒ ๋ฃ์๋๋ฐ๋ ์๋ผ์ ๋ฏธ์ณ๋ฒ๋ฆฌ๊ฒ ์ ์ง์ง ์ ๋ฐ ํ ๋ฒ๋ง ๋์์ค์ผ
๊ทธ๋ฆฌ๊ณ ์ ๊ฒ ์๋ UE5๋ก์ค์ ๋์๊ณ ๋๋ฒ๊ทธ ๋๋ฅด๋ฉด "๋๋ฒ๊ทธ๋ฅผ ํ ์ ์์ต๋๋ค ์ด์ฉ๊ณ " ํ๋ฉด์ ๋ญ ์ค์ ํ์ธํ๋ผ ํ๋๋ฐย ์๋ชป ๋๋ฌ์ AutomationToll๋ก ๋ฐ๊ฟ๋ฒ๋ฆฐ ํ ๋๋ฒ๊ทธ ์ฝ์ ์ฐฝ๋ง ๋์ด.. ์ด๊ฑด ๋ญ ์ฐ์งธ์ผํจ ์ง์ง ์ ๋ฐ ์ฌ๋ ํ ๋ช
์ด๋ ค์ฃผ์ญ์ผ
์ฃฝ์ด
์์ปท์ ๋ง์?(์ค์)
๊ฐ์ด๋ณด์ฌ์ค
์๋ฌ ๋ด์ฉ ๊ธ์ด์ gptํํ ๋ฌผ์ด๋ด. ์ฌ๊ธฐ๊ฐค๋ผ๋ค ๋๋ค์๋ณด๋ค gpt๊ฐ ์ฝ๋ฉ ๋ ์ํจ - dc App
์ปดํ์ผ๋ฌ ์๋ฌ ๋ฌธ๊ตฌ๋ฅผ ์ฝ๊ณ ๋ฌธ์ ๋ฅผ ์ถ์ ํด๋ด
EnhancedInput ์ถ๊ฐ ์ํ๊ฒ ์ง
์ฝ๋ ๋ณต๋ถํ๊ณ ๋์ Unreal ํ์ผ์ ์๋ ๊ฑฐ Generate ํ๊ณ ์ ๊ทผํ์ญ์
์ ๊ฑฐ ์๋ฌ๋๋๊ฑฐ๋ฉด ๋ชจ๋ ์ถ๊ฐ ์ํ๋ฏ?
Build.cs ์ EnhancedInput ์ถ๊ฐํ์
https://code-art-gallery.tistory.com/11