So I have a function ‘LaunchGrenade’ which works as it should, except for the crash when spawning a second actor
void ABaseCharacter::LaunchGrenade()
{
FActorSpawnParameters parameters;
parameters.Owner = this;
parameters.Name = "Grenade";
FTransform transform = GetTransform();
AGrenade *grenade = (AGrenade*)GetWorld()->SpawnActor( AGrenade::StaticClass(),&transform, parameters);
if (grenade)
{
grenade->SetGrenadeInfo(_GrenadeSlots[_SelectedGrenade]);
grenade->Launch(GrenadeLaunchSpeed);
}
}
The issue is, when I call this function again before the previous grenade has been destroyed it crashes on the line below when calling World->SpawnActor().
I don’t understand this, because the behavior that it’s giving me is that when I call ‘SpawnActor’ is the actor it’s trying to initialize is the same actor that was created before.
What should I do here? There’s something with Spawn Actor that I don’t understand. Perhaps it’s the ‘AGrenade::StaticClass()’?