0 like 0 dislike
Hi there,

I'm using the popcorn samples in Unreal currently and even with the systems I've created myself, the laser or lightning etc is always offset and never hits the target if the source position or emitter is moved off 0,0,0.

For example open the Static_Lightning example, expose the target variable then import to Unreal.

Set the target position to any object in the level. The further you move the source Float3 off 0,0,0 the more the offset the lightning will miss the target.

I've been looking through the documentation and searching for answers and done a lot of testing but haven't been able to fix it. I've also tried creating samplers for the source and target positions without using coordinate float3s, but still the offset exists if the source position is moved off 0,0,0 in Unreal.

Any help much appreciated.

by akttfl (160 points)

2 Answers

2 like 0 dislike
Best answer

Ok so, I managed to find out what's wrong here. I reckon it's a bit tricky x)

The idea is to force the position sample on the Shape to be always in world space, and this is achieved by using a different spawn function than usual : the PostEval function. Set your Spawner Script like so:

And inside UE4, set up your Shape Sampler like this:

By letting your sampler unparented and with 'Use Relative Transform' unticked, your emitter will always sample the true world space position of your shape, even if you are moving either the Emitter actor or the Shape sampler :)

Let me know if it helps !

by PierrePK (1.3k points)
Thanks a lot Pierre! :) Works like a charm.
0 like 0 dislike


I've tried to reproduce this but I don't see what is wrong with the Static_Lightning FX inside Unreal. From where I stand, it's perfectly working, the Target and WorldPosition attributes are both in world space units and will always target the right positions no matter the transforms applied to the Popcorn FX Emitter actor.

Are you sure you haven't added a localspace evolver to the FX, and trying to update positions based on that ? Most of the time the position offsets come from wrong matrix conversion between world and local spaces, maybe you're trying to set values in the wrong order.

Can you send a package of your effect ? I'll try to see what's going on :)

by PierrePK (1.3k points)
Hi Pierre, thanks for testing.
So if in Popcorn I create a new Simple fx.
Add an Attribute Sampler Shape called Target.
Then for the velocity of the simple effect, in the spawner script I Velocity = Target.samplePosition();
This works in popcorn, no matter where i move the attribute sampler shape, the particles will fly towards it.
Then importing to Unreal, if I move the emitter off 0,0,0 the particles will not hit the attribute sampler shape.
https://we.tl/pA3neHpYGM Here is an example file, import to Unreal, add a Popcorn shape sampler, set that sampler in the emitter settings, then move the emitter off 0,0,0 and the particles will be offset and no longer hit the sampler.
I know this must be something simple, any help much appreciated.