I have a very simple Blueprint where I want to apply a Gameplay Effect to the player, and spawn an actor that the player can pickup to recover lost health similar to Sonic’s rings.
The Gameplay Effect is successfully applied to the player, the SpawnActor node executes successfully, and I see the “Hello” printed to the screen, but there is no actor spawned. Before this code is executed the Outliner says there are 3014 actors spawned, and after the code is executed the count remains at 3014, indicating that the actor was in fact not spawned.
The same exact code works in BeginPlay. I’ve scoured Google and I’m at a loss as to how to get the actor to spawn. Maybe this is a bug in the engine? Any help would be appreciated!
For some reason no matter what I do I can’t upload a screenshot to this post, so here’s a link to the image on my Google drive…
I tried implementing equivalent code in C++ and the spawned actor is a valid pointer but it’s still not being spawned in the world. Now I’m even more confused…
AActor* AWGHazard::SpawnActor(AActor* SpawnLocation) {
FVector Location = SpawnLocation->GetActorLocation();
Location.Z += 300.f; // this line is causing the actor to NOT spawn...
FActorSpawnParameters Params;
Params.bNoFail = true;
Params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AActor* SpawnedActor = GetWorld()->SpawnActor(LostPieceClass, &Location, nullptr, Params);
if(SpawnedActor != nullptr) {
LOG_DEBUG_MESSAGE_INFO(-1, TEXT("Hello")); // this is printed to the screen
}
return SpawnedActor;
}
Edit: Ok I figured out that adding 300 to the Z component of the actor’s location vector is causing it not to spawn. Now the question is why?!?!
Edit2: It was a PEBCAK error. As soon as the actor was spawned it was colliding with itself and picking itself up. I added a check for the overlapped actor so that doesn’t happen
1 Like
Edit2: It was a PEBCAK error.
Heh, we’ve all been there.