I am figuring a problem out right now that some projectiles doesn’t spawn everytime they should.
.h
TSubclassOf<class AArrowTowerProjectile> ArrowTowerProjectileBP;
AArrowTowerProjectile* Projectile = nullptr;
.cpp in constructor
static ConstructorHelpers::FObjectFinder<UBlueprint> ProjectileBP (TEXT("Blueprint'/Game/Blueprints/Tower/BP_ArrowTowerProjectile.BP_ArrowTowerProjectile'"));
ArrowTowerProjectileBP = (UClass*)ProjectileBP.Object->GeneratedClass;
and my tick function
void AArrowTower::Tick( float DeltaTime )
{
Super::Tick( DeltaTime );
LastShotTime += DeltaTime;
if (InRangeArray.Num() > 0)
{
if (LastShotTime > 1.f / ShotsPerSecond)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, FString::SanitizeFloat(LastShotTime));
Projectile = World->SpawnActor<AArrowTowerProjectile>(ArrowTowerProjectileBP, ActorLocation, FRotator::ZeroRotator);
Projectile->SetTarget(CalculateNearestNPC());
Projectile->SetDamage(dmg);
LastShotTime = 0.f;
}
}
}
I testet with a simple console output if the shooting part of the Tick-function is working properly but the projectiles are not spawning everytime. I cant see any reasonable behavior here.
Thanks for your help