KBEngine官方论坛

 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 配置 开服
查看: 956|回复: 5

Need some help with KBEngine_UE4_demo: deriving from gameEntity class...

[复制链接]

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
发表于 2017-4-18 19:07:00 | 显示全部楼层 |阅读模式
本帖最后由 DarkWere 于 2017-4-18 19:07 编辑

Hi everyone!
Need some help with kbengine_ue4_demo:

Suppose we need to spawn some different game entities into the level.
In GameModeWorld.cpp we have the following:
Void AGameModeWorld :: onEnterWorld_Implementation ( const UKBEventData * pEventData)  
{
        Const UKBEventData_onEnterWorld * pData = Cast <UKBEventData_onEnterWorld> (pEventData);

        FRotator Rot ( 0.f , 0.f , 0.f );
        FTransform SpawnTransform (Rot, pData-> position);

        If (pData-> isPlayer)
        {
                This is a player. Not interesting...
        }
        Else
        {
                TSubclassOf < class AGameEntity> & AGameEntityClass = GameEntityClassArray [ 0 ];
                Auto DeferredActor = Cast <AGameEntity> (UGameplayStatics :: BeginDeferredActorSpawnFromClass ( this , AGameEntityClass, SpawnTransform));
                IF (DeferredActor! = nullptr )
                {
                        DeferredActor-> entityID = pData-> entityID;
                        DeferredActor-> moveSpeed ​​= pData-> moveSpeed;
                        UGameplayStatics :: FinishSpawningActor (DeferredActor, SpawnTransform);
                }
        }
}

In GameEntityClassArray we have only one reference to GameEntity_BP which is a <AGameEntity> class. Sure we can add another reference to another class, but is has to be a <AGameEntity> class, because all entity handling is performed on <AGameEntity> class (example: findGameEntity, addGameEntity, removeGameEntity and so on). Let's suppose we need to spawn some monster for example. I create a MonsterEntity class, derived from GameEntity class, and also derive a blueprint class for mesh and animation handling.

MonsterEntity.h
#pragma once

#include "ue4_scripts/GameEntity.h"
#include "MonsterEntity.generated.h"
UCLASS ()
class KBENGINE_UE4_DEMO_API AMonsterEntity : public AGameEntity
{
        GENERATED_UCLASS_BODY ()

};

MonsterEntity.cpp
#include "kbengine_ue4_demo.h"
#include "MonsterEntity.h"

But when I try to compile this I've got a linker error:
[4/4] Link UE4Editor-kbengine_ue4_demo-3645.dylib
Undefined symbols for architecture x86_64:
  "AMonsterEntity::AMonsterEntity(FObjectInitializer const&)", referenced from:
      void InternalConstructor<AMonsterEntity>(FObjectInitializer const&) in kbengine_ue4_demo.generated.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ERROR: UBT ERROR: Failed to produce item: /Users/oleg/Documents/Unreal Projects/kbengine_ue4_demo/Binaries/Mac/UE4Editor-kbengine_ue4_demo-3645.dylib
Total build time: 13,26 seconds (Local executor: 0,00 seconds)
Command /Users/Shared/Epic Games/UE_4.15/Engine/Build/BatchFiles/Mac/Build.sh failed with exit code 5

Could somebody tell me what I'm doing wrong ?
Any advice would be greatly appreciated!
Thanks in advance.
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
发表于 2017-4-18 19:53:58 | 显示全部楼层
1>------ Build started: Project: AutomationUtils.Automation, Configuration: Debug Any CPU ------
2>------ Build started: Project: ShaderCompileWorker, Configuration: Development_Program x64 ------
3>------ Build started: Project: TestPAL, Configuration: Debug_Program x64 ------
4>------ Build started: Project: UnrealCEFSubProcess, Configuration: Debug_Program x64 ------
5>------ Skipped Build: Project: UnrealCodeAnalyzer, Configuration: Debug_Program x64 ------
5>Project not selected to build for this solution configuration
6>------ Build started: Project: UnrealFrontend, Configuration: Debug_Program x64 ------
7>------ Build started: Project: UnrealHeaderTool, Configuration: Debug_Program x64 ------
8>------ Build started: Project: UnrealLightmass, Configuration: Debug_Program x64 ------
9>------ Build started: Project: UnrealPak, Configuration: Debug_Program x64 ------
2>  Target is up to date
2>  Deploying ShaderCompileWorker Win64 Development...
2>  Total build time: 0.31 seconds (NoActionsToExecute executor: 0.00 seconds)
10>------ Build started: Project: UnrealVersionSelector, Configuration: Debug_Program x64 ------
8>  Creating makefile for UnrealLightmass (UnrealBuildTool.exe is newer)
1>  AutomationUtils.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationUtils.Automation.dll
11>------ Build started: Project: Localization.Automation, Configuration: Debug Any CPU ------
11>  Localization.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\Localization.Automation.dll
12>------ Build started: Project: OneSkyLocalization.Automation, Configuration: Debug Any CPU ------
12>  OneSkyLocalization.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\OneSkyLocalization.Automation.dll
13>------ Build started: Project: BuildGraph.Automation, Configuration: Debug Any CPU ------
13>  BuildGraph.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\BuildGraph.Automation.dll
14>------ Build started: Project: IOS.Automation, Configuration: Debug Any CPU ------
14>  IOS.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\IOS\IOS.Automation.dll
15>------ Build started: Project: AutomationScripts.Automation, Configuration: Debug Any CPU ------
15>  AutomationScripts.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\AutomationScripts.Automation.dll
16>------ Build started: Project: Mac.Automation, Configuration: Debug Any CPU ------
16>  Mac.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\Mac\Mac.Automation.dll
17>------ Build started: Project: AllDesktop.Automation, Configuration: Debug Any CPU ------
17>  AllDesktop.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\AllDesktop\AllDesktop.Automation.dll
18>------ Build started: Project: Android.Automation, Configuration: Debug Any CPU ------
18>  Android.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\Android\Android.Automation.dll
19>------ Build started: Project: HTML5.Automation, Configuration: Debug Any CPU ------
19>  HTML5.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\HTML5\HTML5.Automation.dll
20>------ Build started: Project: Linux.Automation, Configuration: Debug Any CPU ------
20>  Linux.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\Linux\Linux.Automation.dll
21>------ Build started: Project: TVOS.Automation, Configuration: Debug Any CPU ------
21>  TVOS.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\TVOS\TVOS.Automation.dll
22>------ Build started: Project: Win.Automation, Configuration: Debug Any CPU ------
22>  Win.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\Win.Automation.dll
23>------ Build started: Project: XLocLocalization.Automation, Configuration: Debug Any CPU ------
23>  XLocLocalization.Automation -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationScripts\XLocLocalization.Automation.dll
24>------ Build started: Project: BuildPatchTool, Configuration: Debug_Program x64 ------
8>  Target is up to date
8>  Deploying UnrealLightmass Win64 Debug...
8>  Total build time: 3.13 seconds (NoActionsToExecute executor: 0.00 seconds)
25>------ Build started: Project: BootstrapPackagedGame, Configuration: Debug_Program x64 ------
7>  Creating makefile for UnrealHeaderTool (UnrealBuildTool.exe is newer)
7>  Target is up to date
7>  Deploying UnrealHeaderTool Win64 Debug...
7>  Total build time: 1.83 seconds (NoActionsToExecute executor: 0.00 seconds)
26>------ Build started: Project: kbengine_ue4_demo, Configuration: Debug_Editor x64 ------
3>  Creating makefile for TestPAL (UnrealBuildTool.exe is newer)
3>  Target is up to date
3>  Deploying TestPAL Win64 Debug...
3>  Total build time: 1.30 seconds (NoActionsToExecute executor: 0.00 seconds)
27>------ Build started: Project: AutomationTool, Configuration: Debug Any CPU ------
6>  Creating makefile for UnrealFrontend (UnrealBuildTool.exe is newer)
6>  Target is up to date
6>  Deploying UnrealFrontend Win64 Debug...
6>  Total build time: 4.73 seconds (NoActionsToExecute executor: 0.00 seconds)
28>------ Build started: Project: UnrealWatchdog, Configuration: Debug_Program x64 ------
4>  Creating makefile for UnrealCEFSubProcess (UnrealBuildTool.exe is newer)
4>  Target is up to date
4>  Deploying UnrealCEFSubProcess Win64 Debug...
4>  Total build time: 1.55 seconds (NoActionsToExecute executor: 0.00 seconds)
29>------ Build started: Project: UE4, Configuration: Debug_Editor x64 ------
9>  Creating makefile for UnrealPak (UnrealBuildTool.exe is newer)
9>  Target is up to date
9>  Deploying UnrealPak Win64 Debug...
9>  Total build time: 1.29 seconds (NoActionsToExecute executor: 0.00 seconds)
30>------ Build started: Project: BlankProgram, Configuration: Debug_Program x64 ------
10>  Creating makefile for UnrealVersionSelector (UnrealBuildTool.exe is newer)
10>  Target is up to date
10>  Deploying UnrealVersionSelector Win64 Debug...
10>  Total build time: 1.18 seconds (NoActionsToExecute executor: 0.00 seconds)
31>------ Build started: Project: CrashReportClient, Configuration: Debug_Program x64 ------
24>  Creating makefile for BuildPatchTool (UnrealBuildTool.exe is newer)
24>  Target is up to date
24>  Deploying BuildPatchTool Win64 Debug...
24>  Total build time: 1.63 seconds (NoActionsToExecute executor: 0.00 seconds)
32>------ Build started: Project: MinidumpDiagnostics, Configuration: Debug_Program x64 ------
25>  Creating makefile for BootstrapPackagedGame (UnrealBuildTool.exe is newer)
27>  AutomationTool -> E:\UnrealProjects\UnrealEngine-4.15.1-release\Engine\Binaries\DotNET\AutomationTool.exe
33>------ Build started: Project: CrossCompilerTool, Configuration: Debug_Program x64 ------
25>  Target is up to date
25>  Deploying BootstrapPackagedGame Win64 Debug...
25>  Total build time: 0.67 seconds (NoActionsToExecute executor: 0.00 seconds)
34>------ Skipped Build: Project: UnrealLaunchDaemon, Configuration: Debug_Program x64 ------
34>Project not selected to build for this solution configuration
35>------ Skipped Build: Project: DsymExporter, Configuration: Debug_Program x64 ------
35>Project not selected to build for this solution configuration
36>------ Build started: Project: ShaderCacheTool, Configuration: Debug_Program x64 ------
26>  Creating makefile for kbengine_ue4_demoEditor (no existing makefile)
26>  Building UnrealHeaderTool...
26>  Target is up to date
26>  Total build time: 0.14 seconds (NoActionsToExecute executor: 0.00 seconds)
26>  Parsing headers for kbengine_ue4_demoEditor
26>    Running UnrealHeaderTool "D:\kbe\kbengine_ue4_demo\kbengine_ue4_demo.uproject" "D:\kbe\kbengine_ue4_demo\Intermediate\Build\Win64\kbengine_ue4_demoEditor\Debug\kbengine_ue4_demoEditor.uhtmanifest" -LogCmds="loginit warning, logexit warning, logdatabase error" -Unattended -WarningsAsErrors
26>  Reflection code generated for kbengine_ue4_demoEditor in 8.1346594 seconds
26>  Performing 4 actions (4 in parallel)
26>  kbengine_ue4_demo.generated.cpp
26>  MonsterEntity.cpp
26>  [3/4] Link UE4Editor-kbengine_ue4_demo-Win64-Debug.dll
26>  [4/4] Link UE4Editor-kbengine_ue4_demo-Win64-Debug.lib
26>     Creating library D:\kbe\kbengine_ue4_demo\Intermediate\Build\Win64\UE4Editor\Debug\UE4Editor-kbengine_ue4_demo-Win64-Debug.lib and object D:\kbe\kbengine_ue4_demo\Intermediate\Build\Win64\UE4Editor\Debug\UE4Editor-kbengine_ue4_demo-Win64-Debug.exp
26>     Creating library D:\kbe\kbengine_ue4_demo\Intermediate\Build\Win64\UE4Editor\Debug\UE4Editor-kbengine_ue4_demo-Win64-Debug.suppressed.lib and object D:\kbe\kbengine_ue4_demo\Intermediate\Build\Win64\UE4Editor\Debug\UE4Editor-kbengine_ue4_demo-Win64-Debug.suppressed.exp
26>  Deploying kbengine_ue4_demoEditor Win64 Debug...
26>  Total build time: 28.05 seconds (Local executor: 5.77 seconds)
37>------ Skipped Build: Project: UE4EditorServices, Configuration: Debug_Program x64 ------
37>Project not selected to build for this solution configuration
38>------ Skipped Build: Project: UnrealAtoS, Configuration: Debug_Program x64 ------
38>Project not selected to build for this solution configuration
39>------ Build started: Project: UnrealFileServer, Configuration: Debug_Program x64 ------
28>  Creating makefile for UnrealWatchdog (UnrealBuildTool.exe is newer)
28>  Target is up to date
28>  Deploying UnrealWatchdog Win64 Debug...
28>  Total build time: 1.33 seconds (NoActionsToExecute executor: 0.00 seconds)
40>------ Build started: Project: SlateViewer, Configuration: Debug_Program x64 ------
29>  Performing full C++ include scan (building a new target)
29>  Creating makefile for UE4Editor (UnrealBuildTool.exe is newer)
29>  Target is up to date
29>  Deploying UE4Editor Win64 Debug...
29>  Total build time: 15.41 seconds (NoActionsToExecute executor: 0.00 seconds)
41>------ Build started: Project: SymbolDebugger, Configuration: Debug_Program x64 ------
30>  Creating makefile for BlankProgram (UnrealBuildTool.exe is newer)
30>  Target is up to date
30>  Deploying BlankProgram Win64 Debug...
30>  Total build time: 1.19 seconds (NoActionsToExecute executor: 0.00 seconds)
31>  Creating makefile for CrashReportClient (UnrealBuildTool.exe is newer)
31>  Target is up to date
31>  Deploying CrashReportClient Win64 Debug...
31>  Total build time: 2.03 seconds (NoActionsToExecute executor: 0.00 seconds)
32>  Creating makefile for MinidumpDiagnostics (UnrealBuildTool.exe is newer)
32>  Target is up to date
32>  Deploying MinidumpDiagnostics Win64 Debug...
32>  Total build time: 1.73 seconds (NoActionsToExecute executor: 0.00 seconds)
33>  Creating makefile for CrossCompilerTool (UnrealBuildTool.exe is newer)
33>  Target is up to date
33>  Deploying CrossCompilerTool Win64 Debug...
33>  Total build time: 1.29 seconds (NoActionsToExecute executor: 0.00 seconds)
36>  Creating makefile for ShaderCacheTool (UnrealBuildTool.exe is newer)
36>  Target is up to date
36>  Deploying ShaderCacheTool Win64 Debug...
36>  Total build time: 1.18 seconds (NoActionsToExecute executor: 0.00 seconds)
39>  Creating makefile for UnrealFileServer (UnrealBuildTool.exe is newer)
39>  Target is up to date
39>  Deploying UnrealFileServer Win64 Debug...
39>  Total build time: 2.06 seconds (NoActionsToExecute executor: 0.00 seconds)
40>  Creating makefile for SlateViewer (UnrealBuildTool.exe is newer)
40>  Target is up to date
40>  Deploying SlateViewer Win64 Debug...
40>  Total build time: 2.20 seconds (NoActionsToExecute executor: 0.00 seconds)
41>  Creating makefile for SymbolDebugger (UnrealBuildTool.exe is newer)
41>  Target is up to date
41>  Deploying SymbolDebugger Win64 Debug...
41>  Total build time: 1.66 seconds (NoActionsToExecute executor: 0.00 seconds)
========== Build: 36 succeeded, 0 failed, 9 up-to-date, 5 skipped ==========
柯标
3603661@qq.com
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
发表于 2017-4-18 19:54:15 | 显示全部楼层
// Fill out your copyright notice in the Description page of Project Settings.

#include "kbengine_ue4_demo.h"
#include "MonsterEntity.h"




AMonsterEntity::AMonsterEntity(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
}
柯标
3603661@qq.com
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
发表于 2017-4-18 19:54:28 | 显示全部楼层
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "ue4_scripts/GameEntity.h"
#include "MonsterEntity.generated.h"

/**
*
*/
UCLASS()
class KBENGINE_UE4_DEMO_API AMonsterEntity : public AGameEntity
{
        GENERATED_UCLASS_BODY()
       
       
       
       
};
柯标
3603661@qq.com
回复

使用道具 举报

8

主题

3374

帖子

7586

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
7586
QQ
发表于 2017-4-18 19:55:11 | 显示全部楼层
I have no problem?
柯标
3603661@qq.com
回复

使用道具 举报

11

主题

96

帖子

813

积分

高级会员

Rank: 4

积分
813
 楼主| 发表于 2017-4-18 20:02:30 | 显示全部楼层
Thanks a lot!
I've understood my problem.
Forget a constructor..
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|KBEngine Forum

GMT+8, 2018-12-11 17:53 , Processed in 0.049289 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表