Answer the question
In order to leave comments, you need to log in
Why doesn't the function work in ue4 c++?
There is a SpawnSphere class - it contains the Actor spawn logic; 1 - at BeginPlay, 2 - the function I created, it does not work when called from outside.
SpherePoint.cpp
#include "SpawnSphere.h" - added
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;
}
}
}
}
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
AActor* SpawnSphere;
void ASpawnSphere::FirstSpawn()
{
...
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question