So I'm running Engine v4.0.0 still, but I don't think this is a bug, I'm probably just trying to do it wrong. I'm trying to create an actor that creates 6 or however many instances of a UStaticMesh, and then line them up in a row. The way I went about it was with
but this just crashes the game as soon as I try to put the actor into the scene. I'm pretty sure I'm just doing some C++'ing wrong. The error that's returned is like "SubobjectInits[Index].Sub Object != Subobject". However if I remove the for loop, and just leave the code that's inside it to run once, it creates a second model at (250,0,0) in the world, that stays static there, not moving with the root component. Any ideas or things you'd need more detail on?
My actor's .h file: http://pastebin.com/EzPUMaCh
My actor's .cpp file: http://pastebin.com/SHeUYvVf
Code:
for (int i = 0; i < 10; i++) { TempMesh = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("ModelComp1")); if (TempMesh != NULL && TempMesh->IsValidLowLevel()) { TempMesh->BodyInstance.SetCollisionProfileName("PhysicsActor"); // Collision profiles are defined in DefaultEngine.ini TempMesh->StaticMesh = Mesh.Object; TempMesh->SetRelativeScale3D(FVector(0.25f, 0.25f, 0.25f)); //TempMesh->SetSimulatePhysics(true); TempMesh->SetRelativeLocation(FVector(250*i, 0, 0)); MeshArray.Add(TempMesh); } }
My actor's .h file: http://pastebin.com/EzPUMaCh
My actor's .cpp file: http://pastebin.com/SHeUYvVf
Comment