Hello,
I am trying to created an object that will explode at a random time.
I have made a blueprint off a class I have created. The issue is my random time for all the instances of the blueprint on the map are the same.
I have tried the generating the random number in the constructor as well as in the begin play method however I still cannot seem to get it to work.
float AExplosiveObject::GetRandomDelay()
{
return FMath::RandRange(MinBlowUpDelay, MaxBlowUpDelay);
}
void AExplosiveObject::BeginPlay()
{
Super::BeginPlay();
BlowUpDelay = GetRandomDelay();
}
void AExplosiveObject::Tick(float DeltaTime)
{
//counting time
ExplodeTime += DeltaTime;
//when time exceeds the delay
if (ExplodeTime > BlowUpDelay)
{
Explode();
}
}
What I want is for every explosive object spawned on the map to have its own randomised delay.