使用C++创建静态网眼以进行循环。带有虚幻引擎
这是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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论