Есть класс SpawnSphere - в нем логика спавна Actor; 1 - при BeginPlay, 2 - созданная мною функция, она не срабатывает при вызове извне.
SpherePoint.cpp
#include "SpawnSphere.h" - добавлена
int numberOfDestroy = 0;
void ASpherePoint::OnBeginOverlap(UPrimitiveComponent* OverlappedComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult& SweepResult)
{
if (OtherActor != nullptr)
{
numberOfDestroy++;
Destroy();
if (numberOfDestroy >= 10)
{
ASpawnSphere* s = Cast<ASpawnSphere>(SpawnSphere);
if (s != nullptr)
{
s->FirstSpawn();
numberOfDestroy = 0;
}
}
}
}
SpherePoint.h
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
AActor* SpawnSphere;
SpawnSphere.cpp
void ASpawnSphere::FirstSpawn()
{
...
}