๋ธ…์‹  ํ•‘ํ”„์งˆ๋ฌธ ใ…ˆใ……ํ•จ ์–ธ๋ฆฌ์–ผ 5.3.2ย ์“ฐ๊ณ ์žˆ์Œ ํ”„๋กœ์ ํŠธ ๊ธฐ๋ฐ˜์œผ๋กœ ๋ฐฐ์šฐ๋Š” ์–ธ๋ฆฌ์–ผ ์—”์ง„ 5 ๊ฒŒ์ž„ ๊ฐœ๋ฐœ ๋”ฐ๋ผํ•˜๊ณ  ์žˆ๋Š”๋ฐ

๋„์ €ํžˆ ์•ˆ๋ผ์„œ ๊นƒ์— ์˜ฌ๋ผ์™€์žˆ๋Š” ์†Œ์Šค์ฝ”๋“œ ๋ณต๋ถ™ ํ–ˆ๋Š”๋ฐ๋„ ๋˜‘๊ฐ™์€ ๋ถ€๋ถ„์—์„œ ๋…ธ๊ฐ€๋‹ค ๊ณต์‚ฌํŒ ๋งˆ๋ƒฅ ํ†ตํ–‰๊ธˆ์ง€ ํ‘œ์‹œํŒ์ด ์‚ฌ๋ผ์ง€์ง€๋ฅผ ์•Š์Œ

7cee8174abc236a14e81d2b628f1736cc4f1a8



a04424ad2c06782ab47e5a67ee91766dc28ff1ecd7acc4cfbf13d3c659d0d4211c5d5b152c0254ec100acdef8b40


7eec8375b69c28a8699fe8b115ef046e89b02db3


// 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#ํŒŒ์ผ ์ „๋ฌธ


์ง„์งœ ์ฝ”๋“œ ๋ณต๋ถ™์— ์—์…‹๊นŒ์ง€ ๋‹ค์šด ๋ฐ›์•„ ์ฒ˜ ๋„ฃ์—ˆ๋Š”๋ฐ๋„ ์•ˆ๋ผ์„œ ๋ฏธ์ณ๋ฒ„๋ฆฌ๊ฒ ์Œ ์ง„์งœ ์ œ๋ฐœ ํ•œ ๋ฒˆ๋งŒ ๋„์™€์ค์‡ผ



ae5810a5001276b660b8f68b12d21a1d5c86d23618

๊ทธ๋ฆฌ๊ณ  ์ €๊ฒŒ ์›๋ž˜ UE5๋กœ์„ค์ • ๋์—ˆ๊ณ  ๋””๋ฒ„๊ทธ ๋ˆ„๋ฅด๋ฉด "๋””๋ฒ„๊ทธ๋ฅผ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค ์–ด์ฉŒ๊ณ " ํ•˜๋ฉด์„œ ๋ญ” ์„ค์ • ํ™•์ธํ•˜๋ผ ํ–ˆ๋Š”๋ฐย ์ž˜๋ชป ๋ˆŒ๋Ÿฌ์„œ AutomationToll๋กœ ๋ฐ”๊ฟ”๋ฒ„๋ฆฐ ํ›„ ๋””๋ฒ„๊ทธ ์ฝ˜์†” ์ฐฝ๋งŒ ๋‚˜์˜ด.. ์ด๊ฑด ๋ญ ์šฐ์งธ์•ผํ•จ ์ง„์งœ ์ œ๋ฐœ ์‚ฌ๋žŒ ํ•œ ๋ช… ์‚ด๋ ค์ฃผ์‹ญ์‡ผ