It’s not allowing me to spawn a sphere, I don’t know what to do or if I am on the right track, also is that just a component sphere, would I have to spawn a mesh as well?
Even though I appreciate answers please try to answer the question instead of advice or redirection, seeing how once a thread has a reply no one checks it after. Thanks so much!
USphereComponent is not a “real” sphere. It is an invisible sphere used for collisions and physics. You should look for UStaticMeshComponent and assign a Sphere to it. It will look something like this:
Thanks so much! So I think either somethings wrong with unreal or I am stupid. This spawns a sphere named “SphereMesh” in the scene, correct? It’s still not working for me…
ASpawnFactory::ASpawnFactory()
{
UE_LOG(LogTemp, Warning, TEXT("MyCharacter's second is f"));
this->SphereMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("SphereMeshz"));
this->SphereMesh->AttachTo(GetRootComponent());
static ConstructorHelpers::FObjectFinder<UStaticMesh>SphereMeshAsset(TEXT("StaticMesh'/Engine/BasicShapes/Sphere.Sphere'"));
this->SphereMesh->SetStaticMesh(SphereMeshAsset.Object);
}
LogActor:Warning: GameSession /Game/FlyingBP/Maps/UEDPIE_0_FlyingExampleMap.FlyingExampleMap:PersistentLevel.GameSession_19 has natively added scene component(s), but none of them were set as the actor’s RootComponent - picking one arbitrarily
LogActor:Warning: GameNetworkManager /Game/FlyingBP/Maps/UEDPIE_0_FlyingExampleMap.FlyingExampleMap:PersistentLevel.GameNetworkManager_19 has natively added scene component(s), but none of them were set as the actor’s RootComponent - picking
This will not spawn anything in the game, but the code that danielvmacedo provided will make it so that the ASpawnFactory class will have a root component, and this root component is the SphereMesh that you’re creating. If you wish to spawn something in the scene, you would want to use SpawnActor in the BeginPlay function.
I would suggest following this tutorial to learn some more about spawning actors/meshes, specifically the spawning projectiles section.
Yeap, is right. The code that I posted to you is only to create a base Actor class that has a sphere mesh as its root. To spawn a actor in your world you need to call SpawnActor method from the World. You can see how its done in the link suggested by .