Hi, I am trying to make a weapon respawn point to be put onto the level. The problem is it will not spawn the weapon again after the initial spawn. I will have the codes posted here:
void AWeaponSpawner::BeginPlay()
{
Super::BeginPlay();
SpawnMech();
}
// ...
void AWeaponSpawner::NotifyActorBeginOverlap(AActor* OtherActor)
{
Super::NotifyActorBeginOverlap(OtherActor);
if (!IsOverlappingActor(OtherActor))
{
GetWorldTimerManager().SetTimer(RespawnTimer, this, &AWeaponSpawner::SpawnMech, CoolDown, false);
}
}
void AWeaponSpawner::SpawnMech()
{
if (WeaponClass != nullptr)
{
FActorSpawnParameters PowerUpParams;
PowerUpParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::DontSpawnIfColliding;
WeaponToSpawn = GetWorld()->SpawnActor<AActor>(WeaponClass, GetTransform(), PowerUpParams);
}
}
The actual weapon I am trying to spawn was set to overlap all actors except the trace collision I have for my player(customized collision channel), and once the player overlaps with the weapon, it can be picked up by pressing E, and the weapon mesh will be attached to player’s mesh component.
Right now, after the initial spawn in begin play, the weapon will not spawn.
Thanks in advance!