Quick answer: Cache world position before DetachFromComponent. Reapply via SetNiagaraVariableVec3 after.
Hit effect spawns on enemy. Enemy dies; effect detaches; teleports to origin. Position attribute lost on detach.
The Fix
FVector Pos = NiagaraComp->GetComponentLocation();
NiagaraComp->DetachFromComponent(FDetachmentTransformRules::KeepWorldTransform);
NiagaraComp->SetWorldLocation(Pos);
// or set Niagara variable directly
UNiagaraFunctionLibrary::SetNiagaraVariableVec3(
NiagaraComp, TEXT("User.SpawnLoc"), Pos);
KeepWorldTransform preserves position during detach. SetWorldLocation re-anchors. SetVar replaces the system's position-tracking variable.
Verifying
Effect stays at hit point after detach. Without fix: jumps to origin.
“Cache. Detach. Reapply.”
Related Issues
For Niagara mesh origin, see mesh origin. For user param, see user param.
Cache. Reapply. Stays put.