使用C++创建静态网眼以进行循环。带有虚幻引擎

发布于 2025-01-28 14:12:30 字数 1683 浏览 7 评论 0原文

这是top 的修复 使用它来创建一个字符串,静态网格对象可以接受为唯一标识符,因此发动机不会崩溃,

FName name = *FString::Printf(TEXT("Sphere %i"), i);

我想使用for for for for for for for for for for loop创建我可以稍后引用的静态网格,并通过OSC链接到其他事件。我在弄清楚如何使用createfaultSubobject命名实例时遇到了问题。

编译我的代码时,我会遇到此错误:

S:\UnrealEngine\CPP_LEARNING\ShaderShootEm_000\Source\ShaderShootEm_000\FlowSphere.cpp(19): error C4456: declaration of 'i' hides previous local declaration 
S:\UnrealEngine\CPP_LEARNING\ShaderShootEm_000\Source\ShaderShootEm_000\FlowSphere.cpp(18): note: see declaration of 'i' 
S:\UnrealEngine\CPP_LEARNING\ShaderShootEm_000\Source\ShaderShootEm_000\FlowSphere.cpp(23): error C4800: Implicit conversion from 'int32' to bool. Possible information loss 
S:\UnrealEngine\CPP_LEARNING\ShaderShootEm_000\Source\ShaderShootEm_000\FlowSphere.cpp(23): note: consider using explicit cast or comparison to 0 to avoid this warning 
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\HAL\Platform.h(998): note: see declaration of 'int32'

这是代码

RootComponent = CreateDefaultSubobject<USceneComponent>("SceneComponent");
FVector CurrentLocation = GetActorLocation();
StaticMeshes.Init(NULL,10);
float distance = 0;
int32 i = 0;
 for(int32 i= 0; i < 5; i++)
 {
    FString Number = FString::FromInt(i);
    distance *= i * 100;
    StaticMeshes[i] = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Number %i"),i );
    StaticMeshes[i]->SetRelativeLocation(CurrentLocation + FVector(0.0f, 0.0f, distance));
    StaticMeshes[i]->SetupAttachment(RootComponent);
 }

感谢提前的任何帮助〜

this is the fix at top
use this to create a string that Static Mesh Object can accept as a unique identifier so the engine doesn't crash

FName name = *FString::Printf(TEXT("Sphere %i"), i);

I want to use a for Loop to create static meshes that I can reference later and link to other events over OSC. I am having a problem figuring out how to name the instances using the CreateDefaultSubobject.

I get this error when Compiling my code:

S:\UnrealEngine\CPP_LEARNING\ShaderShootEm_000\Source\ShaderShootEm_000\FlowSphere.cpp(19): error C4456: declaration of 'i' hides previous local declaration 
S:\UnrealEngine\CPP_LEARNING\ShaderShootEm_000\Source\ShaderShootEm_000\FlowSphere.cpp(18): note: see declaration of 'i' 
S:\UnrealEngine\CPP_LEARNING\ShaderShootEm_000\Source\ShaderShootEm_000\FlowSphere.cpp(23): error C4800: Implicit conversion from 'int32' to bool. Possible information loss 
S:\UnrealEngine\CPP_LEARNING\ShaderShootEm_000\Source\ShaderShootEm_000\FlowSphere.cpp(23): note: consider using explicit cast or comparison to 0 to avoid this warning 
C:\Program Files\Epic Games\UE_5.0\Engine\Source\Runtime\Core\Public\HAL\Platform.h(998): note: see declaration of 'int32'

This is the Code

RootComponent = CreateDefaultSubobject<USceneComponent>("SceneComponent");
FVector CurrentLocation = GetActorLocation();
StaticMeshes.Init(NULL,10);
float distance = 0;
int32 i = 0;
 for(int32 i= 0; i < 5; i++)
 {
    FString Number = FString::FromInt(i);
    distance *= i * 100;
    StaticMeshes[i] = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Number %i"),i );
    StaticMeshes[i]->SetRelativeLocation(CurrentLocation + FVector(0.0f, 0.0f, distance));
    StaticMeshes[i]->SetupAttachment(RootComponent);
 }

thanks for any help in advance~

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文