FActorSpawnParameters - how exactly does it work?

Hi !

I am trying to spawn projectile, and make ignore it’s owner, but i don’t quite know how to do it. Im trying to do something like this:

		FActorSpawnParameters params;
		params.Instigator = Controller->GetPawn();
		World->SpawnActor<AProjectileActor>(SpawnLocation, FireDirection, params);

And then in the projectile class, invoke IgnoreActorWhenMoving method.

	if (GetInstigator())
		m_CollisionCapsule->IgnoreActorWhenMoving(GetInstigator(), true);

But it doesn’t work at all. Could someone explain to me how does this FActorSpawnParameters work ? Is it passed to the spawned actor and can be used ? Or am i missing something ?

1 Like

I don’t know if this helps, but if you want to set the collision handling when the object has been spawned (basically the green pin on the Spawn Actor from Class node), you need to set the handling method outside the GetWorld->SpawnActor() function separately.

So like :

AActor* SpawnedActor = GetWorld()->SpawnActor(<ClassReference>, <LocationOfSpawn>);
SpawnedActor->SpawnCollisionHandlingMethod = SpawnActorCollisionHandlingMethod::AlwaysSpawn; //This is basically the green "Collision Handling Override" pin

This might help
https://www.ue4community.wiki/Actor

Do you realise how old this question was? :smiley:

Really?

Since this is STILL the first-ranked Google search result for FActorSpawnParameters, I’ll update it for 2024. The new wiki page for it is here: Actor | Unreal Engine Community Wiki
and to save you a click, here is a syntax example of its usage:

   FActorSpawnParameters SpawnInfo;
    SpawnInfo.Owner = this;
    SpawnInfo.Instigator = GetInstigator();
    SpawnInfo.ObjectFlags |= RF_Transient;
    YourActorReference = GetWorld()->SpawnActor(SpawnInfo);