creating multiple instances of the same actor

so i got the basic code set up

if (i > 0)
	FVector NewLocationd;
	NewLocationd.X = 100;
	NewLocationd.Z = 100;
	NewLocationd.Y = 100;

	NewActor = GetWorld()->SpawnActor<AMyActor>(GetClass(), NewLocationd, FRotator::ZeroRotator);

	NewActor->i = i - 1;
	i = 0; 


the actor i got has a cone shape and goes up because of another function, what i would expect to happen is that this one would be spawned at location x 100 , y 100 and go up along the z axis,

but i still only see the original cone going up not 2 as i would expect, no errors or anything like that so i was wondering if it was because
i set the cone shape in the unreal editor and it doesnt carry over to the newly created actor? if thats the case how do i make it visible as a cube or a cone?

so basically what i am trying to do is creating multiple instance of the same actor, like creating cones that spawn around the world. everything that i have tried so far either produce no result or crash the program.

GetClass() in your SpawnActor call should be the same as AMyActor, otherwise it’s GetClass() is the name of the current class you are writing this call inside of, which is probably a different class than AMyActor, this would cause a crash. I’ve been trying to do the same thing as you, and I don’t have an answer either…

… same problem here… it sounds bit stupid question , but anyway…
… I need to make an array of different “Actors from Content Folder” and them “Spawn” or better say ADD to a specific locations which came from another array.
Something like making map at start with elements from content folder , BUT by code.
So, how can I add them thou… ?

here is the code:

UE_LOG(LogTemp, Warning, TEXT(" ---- spawning ---- "));
AUnitElement*			sample =		GetWorld()->SpawnActor<AUnitElement>(AUnitElement::StaticClass(), FVector::ZeroVector, FRotator::ZeroRotator);

I mean , how can I add this “sample” variable to stage?

… got it working, here is the code:

AUnitElement* sample = GetWorld()->SpawnActor<AUnitElement>(AUnitElement::StaticClass(), FVector::ZeroVector, FRotator::ZeroRotator);
(sample->GetRootComponent())->AttachToComponent(ElementBox, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
FVector temp = UKismetMathLibrary::RandomPointInBoundingBox(ElementBox->Bounds.Origin, ElementBox->Bounds.BoxExtent);

ElementBox is just a container of UBoxComponet inside my class and is attached to the root

ElementBox = CreateDefaultSubobject<UBoxComponent>("Element Box");
RootComponent = ElementBox;

Please, if there is a better solution or some issue with this, let me know… : ) ,