I can spawn things that are made from blueprints, but I have something that needs code that doesn’t spawn.
I know that the code to spawn it has been called, but I put a UE_LOG in BeginPlay()
and a Print String in the blueprint.
This is what I use:
FActorSpawnParameters spawnParams1;
FVector loc = FVector(llocx, llocy, 0);
norot = FRotator(0, 270, 90);
AActor* SpawnActorRef = GetWorld()->SpawnActor<AActor>(compActor, loc, norot, spawnParams1);
if (SpawnActorRef) {
compRef.Add(SpawnActorRef);
}
doug_Scale:
SpawnActor
Are you spawning an actual “AActor” Unreal base class? I’m guessing that would be invisible or not even spawn if it had no root component…
doug_Scale:
SpawnActor
Can leave off the last 2 optional parameters as well. Random spawn actor code snippet from our code which definitely works. This is a unique actor spawed in GameMode BeginPlay().
_soundEffectManager = GetWorld()->SpawnActor<ASoundEffectManager>(FVector(0,0,500), FRotator::ZeroRotator);
It is an actor and it has a USceneComponent as a root
I tried your last suggestion and it didn’t work. What If I make an instance of my actor in the class I want it to be created by. I only need one of this anyway. How would I do this?
Can you drag the C++ actor from the content browser into the map? Then play and it shows up correctly? That would ensure your actor code is valid.
I tried adding it to the map in both C++ and blueprint I can’t get an AActor pointer from it.
I think I can just put this in my player pawn. If only I knew how to edit a texture for it.