UE4でC++をいじりたかった・・・
auです・・・。
UE4でC++を使うぞ!っと思って色々と調べてみたのですが、スタートアップの段階で???状態になってしまいました。
コードの中のどこに記述すればいいんだろうから始まり、色々と調べてみて、記述してみたらエラーを吐いてしまう・・・
実行環境
コードとエラーメッセージ
// Fill out your copyright notice in the Description page of Project Settings. #include "Kismet/GameplayStatics.h" #pragma once #include "CoreMinimal.h" #include "GameFramework/GameModeBase.h" #include "DGGameClear.generated.h" /** * */ UCLASS() class DOTGOAL_API ADGGameClear : public AGameModeBase { GENERATED_BODY() ACharacter* MyCharacter = Cast<ACharacter>(UGameplayStatics::GetPlayerPawn(this, 0)); // if (MyCharacter) // { // // do anything. // } }; ||<< エラーメッセージ >|| Running Mono... Setting up Mono /Users/Shared/Epic Games/UE_4.20/Engine /Users/Shared/Epic Games/UE_4.20/Engine/Binaries/Mac Compiling game modules for hot reload Performing 3 actions (12 in parallel) [1/3] Compile DGGameClear.cpp [2/3] Compile DGGameClear.gen.cpp In file included from /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Intermediate/Build/Mac/UE4Editor/Inc/DotGoal/DGGameClear.gen.cpp:7: In file included from /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/GeneratedCppIncludes.h:6: In file included from /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/Object.h:8: /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/UObjectBaseUtility.h:493:14: error: incomplete type 'ACharacter' named in nested name specifier return IsA(T::StaticClass()); ^~~ /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/Templates/Casts.h:129:22: note: in instantiation of function template specialization 'UObjectBaseUtility::IsA<ACharacter>' requested here return Src && Src->IsA<To>() ? (To*)Src : nullptr; ^ /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/Templates/Casts.h:193:30: note: in instantiation of member function 'TCastImpl<APawn, ACharacter, ECastType::UObjectToUObject>::DoCast' requested here return TCastImpl<From, To>::DoCast(Src); ^ /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Source/DotGoal/DGGameClear.h:18:28: note: in instantiation of function template specialization 'Cast<ACharacter, APawn>' requested here ACharacter* MyCharacter = Cast<ACharacter>(UGameplayStatics::GetPlayerPawn(this, 0)); ^ /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/Engine/Classes/GameFramework/Controller.h:12:7: note: forward declaration of 'ACharacter' class ACharacter; ^ In file included from /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Intermediate/Build/Mac/UE4Editor/Inc/DotGoal/DGGameClear.gen.cpp:7: In file included from /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/GeneratedCppIncludes.h:6: In file included from /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/Object.h:8: /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/UObjectBaseUtility.h:493:15: error: incomplete definition of type 'ACharacter' return IsA(T::StaticClass()); ~^~ In file included from /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Source/DotGoal/DGGameClear.cpp:3: In file included from /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Source/DotGoal/DGGameClear.h:2: In file included from /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/Engine/Classes/Kismet/GameplayStatics.h:7: In file included from /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/Object.h:8: /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/UObjectBaseUtility.h:493:14: error: incomplete type 'ACharacter' named in nested name specifier return IsA(T::StaticClass()); ^~~ /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/Templates/Casts.h:129:22: note: in instantiation of function template specialization 'UObjectBaseUtility::IsA<ACharacter>' requested here return Src && Src->IsA<To>() ? (To*)Src : nullptr; ^ /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/Templates/Casts.h:193:30: note: in instantiation of member function 'TCastImpl<APawn, ACharacter, ECastType::UObjectToUObject>::DoCast' requested here return TCastImpl<From, To>::DoCast(Src); ^ /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Source/DotGoal/DGGameClear.h:18:28: note: in instantiation of function template specialization 'Cast<ACharacter, APawn>' requested here ACharacter* MyCharacter = Cast<ACharacter>(UGameplayStatics::GetPlayerPawn(this, 0)); ^ /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/Engine/Classes/GameFramework/Controller.h:12:7: note: forward declaration of 'ACharacter' class ACharacter; ^ In file included from /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Source/DotGoal/DGGameClear.cpp:3: In file included from /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Source/DotGoal/DGGameClear.h:2: In file included from /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/Engine/Classes/Kismet/GameplayStatics.h:7: In file included from /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/Object.h:8: /Users/Shared/Epic Games/UE_4.20/Engine/Source/Runtime/CoreUObject/Public/UObject/UObjectBaseUtility.h:493:15: error: incomplete definition of type 'ACharacter' return IsA(T::StaticClass()); ~^~ 2 errors generated. 2 errors generated. ERROR: UBT ERROR: Failed to produce item: /Users/ユーザ名/Documents/Unreal Projects/DotGoal/Binaries/Mac/UE4Editor-DotGoal-629.dylib (see ../Programs/UnrealBuildTool/Log.txt for full exception trace) Total build time: 10.28 seconds (Local executor: 0.00 seconds)