首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在“虚幻编辑器”中添加演员并将其移动?

如何在“虚幻编辑器”中添加演员并将其移动?
EN

Stack Overflow用户
提问于 2014-07-01 06:36:38
回答 1查看 1.1K关注 0票数 2

我是游戏开发方面的新手。通过培训课程开始(https://docs.unrealengine.com/latest/INT/Programming/QuickStart/7/index.html),我创建了一个类AMyActorTest扩展AActor:

代码语言:javascript
复制
#include "TestUProject.h"
#include "MyActorTest.h"


AMyActorTest::AMyActorTest(const class FPostConstructInitializeProperties& PCIP)
    : Super(PCIP)
{
    MyNumber = 12;
}

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

    if (GEngine)
    {
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Hello World!"));
        GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::FromInt(MyNumber));
    }

}

我有一个问题,我不能在编辑器中移动到AActor后,将它放在ViewPort中。我读到我为我的演员错过了RootComponent,但我不知道如何添加它(也许我不完全理解演员)。能帮你有我的源代码来解决我的问题吗?这段代码是在训练方面做的。我的目标-增加一个演员,并能够移动和旋转它。

EN

回答 1

Stack Overflow用户

发布于 2015-04-16 15:18:02

请添加这段代码

代码语言:javascript
复制
RootComponent = PCIP.CreateDefaultSubobject<USceneComponent>(this, TEXT("Root"));

你的构造函数。就这样。如果您想添加其他组件,可以使用类似的代码(本例创建UInstancedStaticMeshComponent:

代码语言:javascript
复制
UInstancedStaticMeshComponent* instancedComp = PCIP.CreateDefaultSubobject<UInstancedStaticMeshComponent>(RootComponent, TEXT("SubMeshInstanced"));
instancedComp->AttachTo(RootComponent);  // this is important!

// this part is specific to this component 
// (although all are common to other types of your Root subitems)

instancedComp->SetStaticMesh(mesh);       

instancedComp->SetMaterial(0, material);
instancedComp->bOwnerNoSee = false;
instancedComp->bCastDynamicShadow = false;
instancedComp->CastShadow = false;
instancedComp->SetHiddenInGame(false);
instancedComp->SetMobility(EComponentMobility::Static);
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24503835

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档