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);