• 카테고리

    질문 & 답변
  • 세부 분야

    게임 프로그래밍

  • 해결 여부

    미해결

2강 캐릭터와 입력시스템: compile error로 인해 코드를 적용할 수 없습니다.

23.11.15 23:37 작성 23.11.15 23:38 수정 조회수 767

0

34분 15초 부터 시작해서 강의 끝까지 들었습니다.

선생님 코드에서 compile error 표시가 있어도 빌드랑 ctrl + f5를 통한 Editor 실행까지 잘 수행되는 것을 확인했습니다.

 

 

하지만 제 환경에서는 compile error 표시를 해결하지 않으면 아무것도 수행할 수 없었습니다.

수업 자료에 있던 zip 파일의 소스 코드를 복붙해서 오타가 있는지 확인했는데도, compile error가 발생합니다.

이를 해결하고 싶습니다.

Build started...
1>------ Build started: Project: ArenaBattle, Configuration: Development_Editor x64 ------
2>------ Skipped Build: Project: UE5, Configuration: BuiltWithUnrealBuildTool Win64 ------
2>Project not selected to build for this solution configuration 
1>Using bundled DotNet SDK version: 6.0.302
1>Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" ArenaBattleEditor Win64 Development -Project="C:\Unreal Projects\ArenaBattle\ArenaBattle.uproject" -WaitMutex -FromMsBuild
1>Log file: C:\Users\kdh\AppData\Local\UnrealBuildTool\Log.txt
1>Invalidating makefile for ArenaBattleEditor (ABCharacterPlayer.cpp.obj.response modified)
1>Building ArenaBattleEditor...
1>Using Visual Studio 2022 14.34.31947 toolchain (C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.34.31933) and Windows 10.0.18362.0 SDK (C:\Program Files (x86)\Windows Kits\10).
1>[Upgrade]
1>[Upgrade] Using backward-compatible include order. The latest version of UE has changed the order of includes, which may require code changes. The current setting is:
1>[Upgrade]     IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1
1>[Upgrade] Suppress this message by setting 'IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_2;' in ArenaBattleEditor.Target.cs.
1>[Upgrade] Alternatively you can set this to 'EngineIncludeOrderVersion.Latest' to always use the latest include order. This will potentially cause compile errors when integrating new versions of the engine.
1>[Upgrade]
1>Determining max actions to execute in parallel (8 physical cores, 16 logical cores)
1>  Executing up to 8 processes, one per physical core
1>  Requested 1.5 GB free memory per action, 5.08 GB available: limiting max parallel actions to 3
1>Building 4 actions with 3 processes...
1>[1/4] Link [x64] UnrealEditor-ArenaBattle.dll cancelled
1>[2/4] WriteMetadata ArenaBattleEditor.target cancelled
1>[3/4] Link [x64] UnrealEditor-ArenaBattle.lib cancelled
1>[4/4] Compile [x64] ABCharacterPlayer.cpp
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(58): error C2672: 'ULocalPlayer::GetSubsystem': no matching overloaded function found
1>C:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Engine\Classes\Engine\LocalPlayer.h(332): note: could be 'TSubsystemClass *ULocalPlayer::GetSubsystem(const ULocalPlayer *)'
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(58): note: 'initializing': cannot convert from 'APlayerController *' to 'const ULocalPlayer *'
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(58): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or parenthesized function-style cast
1>C:\Program Files\Epic Games\UE_5.2\Engine\Source\Runtime\Engine\Classes\Engine\LocalPlayer.h(322): note: or       'TSubsystemClass *ULocalPlayer::GetSubsystem(void) const'
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(58): note: 'TSubsystemClass *ULocalPlayer::GetSubsystem(void) const': expects 0 arguments - 1 provided
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(88): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(88): error C2146: syntax error: missing ';' before identifier 'Rotation'
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(88): error C2065: 'Rotation': undeclared identifier
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(89): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(89): error C2086: 'const int FRotater': redefinition
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(88): note: see declaration of 'FRotater'
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(89): error C2146: syntax error: missing ';' before identifier 'YawRotation'
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(89): error C2065: 'Rotation': undeclared identifier
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(89): error C3861: 'YawRotation': identifier not found
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(91): error C2065: 'YawRotation': undeclared identifier
1>C:\Unreal Projects\ArenaBattle\Source\ArenaBattle\Character\ABCharacterPlayer.cpp(92): error C2065: 'YawRotation': undeclared identifier
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(44,5): error MSB3073: The command ""C:\Program Files\Epic Games\UE_5.2\Engine\Build\BatchFiles\Build.bat" ArenaBattleEditor Win64 Development -Project="C:\Unreal Projects\ArenaBattle\ArenaBattle.uproject" -WaitMutex -FromMsBuild" exited with code 6.
1>Done building project "ArenaBattle.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========
========== Build started at 오후 11:32 and took 07.270 seconds ==========

이처럼 해당 클래스를 찾을 수 없다는 compile error가 계속 발생했습니다.

10000자 제한으로 답글에 코드를 올리겠습니다.

답변 2

·

답변을 작성해보세요.

1

음 하나 바로 보이는게, FRotator인데 FRotater라고 쓰셨네요.
꾸준히 따라하시다보면 적응되는 순간이 옵니다.
추가로 5.2 쓰시는 것으로 보이는데, 가급적이면 5.1로 진행해주시는 것을 추천드립니다.

void AABCharacterPlayer::Move(const FInputActionValue& Value)
{
	FVector2D MovementVector = Value.Get<FVector2D>();

	const FRotator Rotation = Controller->GetControlRotation();
	const FRotator YawRotation(0, Rotation.Yaw, 0);

	const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
	const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);

	AddMovementInput(ForwardDirection, MovementVector.X);
	AddMovementInput(RightDirection, MovementVector.Y);
}
즐겁다님의 프로필

즐겁다

질문자

2023.11.16

감사합니다.

오타를 바로 잡고 나서

#include "InputActionValue.h"

#include "InputMappingContext.h"

#include "EnhancedInputComponent.h"

#include "EnhancedInputSubsystems.h"

위 헤더를 인식하지 못해서 uproject를 generated visual studio... 를 해줬더니 해결됐네요!

이런 경우에는 버전 문제일까요..?

0

즐겁다님의 프로필

즐겁다

질문자

2023.11.15

10000자 제한으로 인해서 답글로 코드를 올립니다.

아래가 제가 작성한 ABCharacter.cpp 파일입니다.

// Fill out your copyright notice in the Description page of Project Settings.


#include "Character/ABCharacterPlayer.h"
#include "Camera/CameraComponent.h"
#include "GameFramework/SpringArmComponent.h"

#include "InputMappingContext.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"


AABCharacterPlayer::AABCharacterPlayer()
{
	// Camera
	CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
	CameraBoom->SetupAttachment(RootComponent);
	CameraBoom->TargetArmLength = 400.0f;
	CameraBoom->bUsePawnControlRotation = true;

	FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
	FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName);	// springArm에 자동으로 달라붙는다.
	FollowCamera->bUsePawnControlRotation = false;

	// Input
	static ConstructorHelpers::FObjectFinder<UInputMappingContext> InputMappingContextRef(TEXT("/Script/EnhancedInput.InputMappingContext'/Game/ArenaBattle/Input/IMC_Default.IMC_Default'"));
	if (InputMappingContextRef.Object != nullptr)
	{
		DefaultMappingContext = InputMappingContextRef.Object;
	}

	static ConstructorHelpers::FObjectFinder<UInputAction> InputActionMoveRef(TEXT("/Script/EnhancedInput.InputAction'/Game/ArenaBattle/Input/Actions/IA_Move.IA_Move'"));
	if (InputActionMoveRef.Object != nullptr)
	{
		MoveAction = InputActionMoveRef.Object;
	}

	static ConstructorHelpers::FObjectFinder<UInputAction> InputActionJumpRef(TEXT("/Script/EnhancedInput.InputAction'/Game/ArenaBattle/Input/Actions/IA_Jump.IA_Jump'"));
	if (InputActionJumpRef.Object != nullptr)
	{
		JumpAction = InputActionJumpRef.Object;
	}

	static ConstructorHelpers::FObjectFinder<UInputAction> InputActionLookRef(TEXT("/Script/EnhancedInput.InputAction'/Game/ArenaBattle/Input/Actions/IA_Look.IA_Look'"));
	if (InputActionLookRef.Object != nullptr)
	{
		LookAction = InputActionLookRef.Object;
	}

}

void AABCharacterPlayer::BeginPlay()
{
	
	Super::BeginPlay();

	APlayerController* PlayerController = CastChecked<APlayerController>(GetController());
	if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem< UEnhancedInputLocalPlayerSubsystem>(PlayerController))
	{
		// mapping context 추가
		Subsystem->AddMappingContext(DefaultMappingContext, 0);	// 우선순위를 지정해서 다양한 input이 서로 겹칠 때 우선순위가 높은 입력을 먼저 처리

		// 런타임에서 해당 함수를 이용해서 뺄 수 있다.
		// Subsystem->RemoveMappingContext(DefaultMappingContext);
	}
}

void AABCharacterPlayer::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);

	// 반드시 Enhance Input System을 쓰도록 세팅
	// CastChecked를 통해 해당 input system을 쓰지 않으면 에러를 발생시킨다.
	UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent);

	// 생성자에서 만든 Action을 함수와 binding 한다.
	// Jump와 StopJumping는 Character가 제공하는 함수 API이다.
	EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::Jump);
	EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::StopJumping);
	EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AABCharacterPlayer::Move);
	EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AABCharacterPlayer::Look);
}

void AABCharacterPlayer::Move(const FInputActionValue& Value)	// Value에 xy 값을 가져온다.
{
	FVector2D MovementVector = Value.Get<FVector2D>();

	const FRotater Rotation = Controller->GetControlRotation();
	const FRotater YawRotation(0, Rotation.Yaw, 0);

	const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
	const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);

	// Value에서 가져온 x, y 값을 Movement Component와 연결한다.
	AddMovementInput(ForwardDirection, MovementVector.X);
	AddMovementInput(RightDirection, MovementVector.Y);
}

void AABCharacterPlayer::Look(const FInputActionValue& Value)
{
	FVector2D LookAxisVector = Value.Get<FVector2D>();

	//  controller의 회전 설정으로 카메라의 springArm이 해당 component를 바라보도록 설정
	AddControllerYawInput(LookAxisVector.X);
	AddControllerYawInput(LookAxisVector.Y);
}