WARNING : This site is outdated and the PopcornFX team will no longer answer your questions here.
For all support questions please go to our Discord server
0 like 0 dislike

I'm having trouble trying to get my particles to collide with a shape defined in a shape attribute sampler. It seems to work in the editor but not in Unreal. It may or may not be related to this bug although cascade now collides with the world properly and popcorn still doesn't.

Here's what i have in the PFX editor:

And then in Unreal:

I know that the mesh sampling is working because in addition to the collision my spawn script instantly kills any particle that tries to spawn inside the shape and that is working. But the collision isn't working at all.

by feanix (1.2k points)

1 Answer

0 like 0 dislike
Best answer

Thanks for the detailed explanation.

The issue here is that you try to access an attribute sampler during the particle's lifetime (evolve), which is not supported yet. If you move the shape attribute sampler inside your layer, making it become a classic shape sampler, it will work.

Basically if you override the default attribute sampler in engine, it will fallback to the default shape description defined within the editor.

What was the script doing ? kill(RoachCollision.contains(Position)); ?

Or using a collision/physics evolver ?

What you can do is use an attribute to define the shape's position + radius and you can easily detect that in script.

Or you can just move the attribute sampler in the samplers list of the layer.

Another option might be a mistmatch with the attribute samplers transforms, make sure everything is fine here too.

by HugoPKFX (17.7k points)
Thanks for all the helpful information here.

Killing the roaches inside the shape is working well and is done in the spawn script. My method is probably not very good, though! I use this:

Life = iif(RoachCollision.contains(Position) == true, 0, 5);

I'll probably switch to your method instead.

What I would like to do is be able to have the roaches moving around in a defined area in our levels to stop them going into walls or out over the edges of holes in the ground. I was hoping I could use a shape collection attribute to block in these areas. I could then also use attractors to cause them to scatter away from disturbances and towards safe areas (under furniture or whatever). Is there a better way to approach this?

EDIT: Ahh, I see that kill is not available in spawn scripts. In this case, I will continue to use my method

EDIT2: In case it helps, you can get the PKFX project here:
Hi Feanix,

exactly kill cannot be used at spawn time, only in an evolver script. I guessed you were doing those Shape.contains() check at particle evolve but it seems you are not.

So basically you can stick with the attribute sampler method (and you can even use a shape collection) as long as you do checks inside the particle's Spawn Script.

The only issue I see would be how you setup the attribute sampler transforms in unreal, as you sample the attribute sampler in Eval() in the Spawner Script, this is localspace (object space).

Can you give it a try by placing the attribute sampler as a child of your emitter and use "Attr sampler Relative Tr"
I think there is a fundamental miscommunication here. My problem  is not the spawning, my problem is that the collision is not working. Sorry for the confusion. To be clear, roaches not spawning is working in Unreal. It's just that they do not collide with the shape so nothing stops then from entering into the space after they spawn.
No worries, like I said in the original answer, the issue here is that you are accessing an attribute sampler during the particle's lifetime:

You use a collision evolver with "RoachCollision" as Collider, which is not possible because it's an attribute sampler, and requires the "attribute samplers at evolve feature" which isn't implemented right now.

Like I said you can either:
- Move the RoachCollision out of the attribute samplers list inside the classic samplers list
- Use attributes to define the attr sampler position / radius

TLDR; you cannot have a collision evolver with an attribute sampler as Collider.

Another option: Use "FilterID" to only collide with specific collision objects in UE4 which would be the same as using attribute samplers in your FX, but uses PhysX for collisions
Oh, sorry! I just didn't understand what you were saying. :( Thank you for clearing that up.

Should the collision be working for world collision by default? Or only when specifying specific items with FilterID? When I placed a the default cube mesh in Unreal my roaches still did not collide with it.
No worries :)

Just make sure not to have both Physics & Collision evolvers at the same time (Physics should be enough).
Also, enable OneWay collision mode to have basic collisions.

By leaving FilterID to 0 it will collide with every UE4 object having "Collision mode" set to "BlockAll".
Then if you want to collide only with some objects, FilterID is really just an index inside the PopcornFX's Collision presets.

If you want an example of that you can download the content examples from the github repo, scene number 06_Physics contains a filterID example.
Also, some informations can be found here: http://wiki.popcornfx.com/index.php/UE4/Collisions

Using a custom filter ID should make collisions more performant as it discards undesired geometry