I’m having some troubles with niagara and spline, I wish to make a laser spell going from the caster’s hand to the enemy, the problem is that once I attach my spline to the character the FX won’t move along it even though it does follow the spline if I just skip the “AttachActorToComponent” node, I think pictures will explain better.
First, my spline actor, as you can see the fx is following the spline perfectly :
Second, my spell’s blueprint (using the GAS). The SpellCast custom event is just a sphere trace to set the location of the third spline point to the enemy:
Third, I cast the spell the spline’s actor attaches to the caster’s hand and the third point of the spline is placed on the enemy. As you can see the FX does not move along the spline as it should, even though in the background it’s working properly on an unattached actor.
Fourth, in GA_Laser(second picture), i unticked the branch’s boolean and thus skipped the “AttachActorToComponent” , so the BP_LaserSpline actor spawns and the end of the spline follows the enemy and the fx follows the spline and it just works.
It just doesn’t work when I attach the actor to the caster and I dont know why.
Fifth, a picture of the Niagara Module Script that I used to tell the particles to follow the spline.
I’m using the local space sample spline node instead of the world space one because when my emitter was using the
world space it would spawn at 0 0 0 of the world, now since I’m using local space I guess it spawns at 0 0 0 of the BP_LaserSpline actor which happens to be the character’s hand.
I hope that was clear enough, thanks for reading and eventually helping.
Hey there, sorry for bumping this old topic but I have this EXACT same issue and have searched far and wide for an answer from Google, to Discord, to Youtube and everywhere in between. Except for me the issue is a particle I spawn in Sequencer for a cinematic I’m working on. Did you happen to find the solution for this? I’m guessing it’s either the blueprint or the niagara script module that’s messing something up or missing something. I have my set-up almost exactly the same as yours and the same issues crop up (non-local spawns at 0,0,0, local spawns at hand, spline is visibly moving with the actor but particles refuse to stay on spline, etc.). The effect shows up properly in the level when dragged onto the level normally, and also in the Blueprint itself.
To dig out more about the problem, you may refer to NiagaraDataInterfaceSpline.cpp
USplineComponent* SplineComponent = InstData->Component.Get();
if (SplineComponent == nullptr)
{
if (SplineUserParameter.Parameter.IsValid() && InstData && SystemInstance != nullptr)
{
// Initialize the binding and retrieve the object. If a valid object is bound, we'll try and retrieve the Spline component from it.
// If it's not valid yet, we'll reset and do this again when/if a valid object is set on the binding
UObject* UserParamObject = InstData->UserParamBinding.Init(SystemInstance->GetInstanceParameters(), SplineUserParameter.Parameter);
InstData->CachedUserParam = UserParamObject;
if (UserParamObject)
{
if (USplineComponent* UserSplineComp = Cast<USplineComponent>(UserParamObject))
{
if (IsValid(UserSplineComp))
{
SplineComponent = UserSplineComp;
}
}
else if (AActor* UserParamActor = Cast<AActor>(UserParamObject))
{
SplineComponent = UserParamActor->FindComponentByClass<USplineComponent>();
}
else
{
//We have a valid, non-null UObject parameter type but it is not a type we can use to get a skeletal Spline from.
UE_LOG(LogNiagara, Warning, TEXT("Spline data interface using object parameter with invalid type. Spline Data Interfaces can only get a valid Spline from SplineComponents or Actors."));
UE_LOG(LogNiagara, Warning, TEXT("Invalid Parameter : %s"), *UserParamObject->GetFullName());
UE_LOG(LogNiagara, Warning, TEXT("Niagara Component : %s"), *GetFullNameSafe(Cast<UNiagaraComponent>(SystemInstance->GetAttachComponent())));
UE_LOG(LogNiagara, Warning, TEXT("System : %s"), *GetFullNameSafe(SystemInstance->GetSystem()));
}
}
else
{
// The binding exists, but no object is bound. Not warning here in case the user knows what they're doing.
}
}
else if (SoftSourceActor != nullptr)
{
SplineComponent = SoftSourceActor->FindComponentByClass<USplineComponent>();
}
else if (USceneComponent* AttachComp = SystemInstance->GetAttachComponent())
{
if (AActor* Owner = AttachComp->GetAttachmentRootActor())
{
SplineComponent = Owner->FindComponentByClass<USplineComponent>();
}
}
InstData->Component = SplineComponent;
}
By default the Niagara system gets the spline component from GetAttachmentRootActor(). When you attach your Niagara actor to a new target, that becomes the root actor and doesn’t have a spline. So we have to assign it in advance.