C++ Battery Collector: Toggling the Spawn Volumes | 19 | v4.9 Tutorial Series | Unreal Engine

preview_player
Показать описание
Add code to your spawning volume so that it will only spawn when a boolean variable is true.

(00:05) - Recap & Intro
(00:57) - Creating a Spawn Toggle Function
(05:39) - Tracking the Spawn Volume
(08:41) - Casting Actors to Spawn Volumes
Рекомендации по теме
Комментарии
Автор

At 7:40 it's easy to do without the helper GetAllActorsOfClass function:

#include "EngineUtils.h"

for (TActorIterator<ASpawnVolume> It(GetWorld()); It; ++It) {
SpawnVolumeActors.Add(*It);
}

There is less code, no casts, temporary array and hidden cycles so this code should run faster as well. Actually GetAllActorsOfClass is the wrapper function for the above code and should be used mainly in blueprints.

visualcortex
Автор

This is where Ihad spawning issues. I had to perform my own checks. Like calling SetSpawningActive(true) from BeginPlay before trying to call it from another class. It worked fine. Now to try and make it work from GameMode. I like to check everything that has been declared and defined before moving on. Less errors and less stress, it also provides a clearer understanding of each individual puzzle piece in this enigma known as Battery Collector.
Game On!

jmbstudio
Автор

For anyone getting an 'error C4668' when compiling at the end of the video. Check to make sure you have #include "GameFramework/Actor.h" and not #include "Actor.h"

jasmineyoung
Автор

So GetAllActorsOfClass gets all the ASpawnVolume actors in the scene. Why do we have to loop thrue that array again and check if these are ASpawnVolume Actors? (o.O);

GamedevCala
Автор

My landscape gonna have Procedural Foiliage Spawner, is this gonna count them in too? It would be a mess

yayaraft