0 like 0 dislike
831 views
Hey there,

I was hoping there was a way to move a shape sampler through a script so that I could move the Localization position through a float 3 attribute.

In the script reference it shows how to get the return of the float3 position, but doesn't mention how to set the float3 position.
by michael-kerr-graham (510 points)

1 Answer

0 like 0 dislike

Hi Michael,

Indeed you can't modify samplers from particle script, you can only read data from them, and the same goes for attributes.

Solution 1

You could use Attribute Samplers which are just samplers but placed under the "Attribute Samplers" category of your FX.

What happens is that you'll be able to override/modify those samplers inside the engine: say you create a Shape attribute sampler, then you'll be able to override this shape with a new Shape sampler actor in UE4, and move it directly in Unreal, and the same method is valid in Unity/Custom engine.

More info:

Solution 2

 

You could add a "MyShapePosition" Attribute as a float3 that would be set in engine, having a "MyShape" shape sampler that is at the origin, and sample it that way (in the Spawner Script for example):

 

function void    Eval()

{

     Position = MyShape.samplePosition() + MyShapePosition;

}

 

This float3 attribute would only act as an offset. Depending on whether you sample this shape in local/world space context, you would need MyShapePosition to be setup accordingly.

An advantage is that it would allow you to sample the MyShape sampler at particle evolve time, which attribute samplers don't allow right now.

 

Hope this helps.

by seedmanj (17.2k points)
Hey Hugo,

Thanks for that wiki link, was what I needed to get the effect working. Now the only issue I still have is that I cannot control shape attributes through blueprints.

I'm trying to setup a blueprint with the shape samples and the emitter inside the blueprint, but when I try to set the shape samples it keeps trying to get shapes from the level and I cannot set them from the shape samplers in the blueprint. As shown here:

http://imgur.com/a/bAHgM

This majorly limits how I can reuse an effect that has shape samplers.
Hi Michael,

Sorry for the not very user friendly interface on attribute samplers, there is definitely room for improvements here.

So basically you can use the small text box right under your attribute sampler name and type in a component name (that exists within this blueprint). And instead of choosing an actor inside your level it will choose the component if it exists as the current shape sampler (component)

http://i.imgur.com/lgJrQr7.jpg

After specifying your existing component, make sure to compile the blueprint (maybe reload the effect) and it should work correctly.

Now for the actual shape tweaking at runtime it is only C++ exposed right now, we could definitely add blueprint access. Do you need to change things like Radius/Height or everything like Shape Type etc ?

Let us know how it goes.
...