UGameplayStatics::SpawnEmitterAttached issue

UGameplayStatics::SpawnEmitterAttached works strange, maybe it is not a bug, but i do not know what the reason then.

if i spawn particle FX using this:UGameplayStatics::SpawnEmitterAttached(ParticleFX, GetMesh(), AttachSocketName, GetActorLocation(), GetActorRotation(), EAttachLocation::KeepRelativeOffset, true);
even if EAttachLocation is SnapToTarget
then particle FX is not attached to mesh and effect plays in some random location of the map.

but if i spawn particle FX using: UGameplayStatics::SpawnEmitterAttached(ParticleFX, GetMesh(), AttachSocketName); then particle FX is attached to mesh to socket right.

so why it won’t work if i set location and rotation i do not know, maybe chain of calls is impotant?
the final function looks so:

void AXZ_Character::SetRagdollPhysics(float LifeSpan)
{
	if (!bInRagdoll)
	{
		if (!IsPendingKill())
		{
			bInRagdoll = true;

			SetActorEnableCollision(true);

			GetCharacterMovement()->ForceReplicationUpdate();

			GetMovementComponent()->StopMovementImmediately();
			GetCharacterMovement()->DisableMovement();
			GetMovementComponent()->SetComponentTickEnabled(false);

			GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
			GetCapsuleComponent()->SetCollisionResponseToAllChannels(ECR_Ignore);

			UGameplayStatics::SpawnEmitterAttached(ParticleFX, GetMesh(), AttachSocketName);

			static FName RagdollCollisionProfileName(TEXT("Ragdoll"));

			GetMesh()->SetCollisionProfileName(RagdollCollisionProfileName);
			GetMesh()->SetAllBodiesSimulatePhysics(true);
			GetMesh()->SetSimulatePhysics(true);
			GetMesh()->WakeAllRigidBodies();
			GetMesh()->bBlendPhysics = true;

			GetMesh()->AddImpulse(ExplosionImpulse, NAME_None, true);

Hey h20,

Thank you for the bug report. I was able to reproduce the issue and have submitted it to the development team. You can follow the progress of it here: https://issues.unrealengine.com/issue/UE-34482

Furthermore, if you have the source code of the engine, you can update the SpawnEmitterAttached function as such:

Change:

PSC->RelativeLocation = Location;
PSC->RelativeRotation = Rotation;

To:

PSC->SetWorldLocation( Location );
PSC->SetWorldRotation( Rotation );

If you need more information on how to get the source code for UE4, you can read about it here:

[][2]

[2]:

Hi. Good to know. Tnx. I have also another strange bug which can be related to this one maybe: