0 like 0 dislike

How to make VFX that are not in the center follow the camera?


Then I tried this but not what I really wanted. I want it to rotate with the camera.

asked by di_sk8portugal (160 points)
Thanks a lot that is really what I needed :)

2 Answers

1 like 0 dislike
Best answer

To build upon what Paul said, the idea is to reconstruct each particle's position in an evolve script using the view.axisUp() and view.axisSide() functions.

I don't know how you constructed your effect, but I see two main ways:

1- 1 particle, 4 renderers (one per digit)

A single particle will be better if the counter needs to move around, with a physics evolver, turbulence, etc. You'll only do the position computations once, and it'll be easier to avoid the digits drifting away.

Here, your effect could look like:

Particle fields:
    float3 Position; // "Position" is the real particle position
    float3 Position1; // first digit
    float3 Position2; // second digit
    float3 Position3; // third digit
    float3 Position4; // fourth digit

4 screen aligned quad renderers, each bound to 'Position1, 'Position2', 'Position3', 'Position4'

- Localspace evolver (optional)

Use this if you want the effect to stick to a moving game-object, you can leave the default enter/leave settings.

- Script evolver:
    Position1 = Position + view.axisSide() * -1.5;
    Position2 = Position + view.axisSide() * -0.5;
    Position3 = Position + view.axisSide() * 0.5;
    Position4 = Position + view.axisSide() * 1.5;

Here, all digits have a distance of 1 unit between them.
There's no need to use planar-aligned renderers here, as the billboards _and_ their centers will be aligned to the camera plane.
Note that using the view axes is equivalent to doing a matrix transform.
If you want your second digit to be located in (x,y) = { -1.3, 2.75 } in view-space relative to 'Position', you'd do:
Position2 = Position + view.axisSide() * -1.3 + view.axisUp() * 2.75;
which is the same thing as multiplying 'float3(-1.3, 2.75, 0)' by the view matrix and offsetting it by 'Position - view.position()'

2- 4 particles (one per digit), 1 renderer

This one is slightly less straightforward on the placement side of things. You can take a look at the "ParticleText.pkfx" effect in the "SampleParticlesEditor" online package accessible from the project launcher to see it in action.
Hope this helps,
answered by Julien (31.9k points)
Thanks dude! You saved me a lot of headache xD This is what I needed thanks again! :D
hmmm for some reason in game it doesn't rotate while in Popcorn preview it does.
Only the billboards rotate in where they are at.
looks like this game engine doesn't support multiple position variables -shrugs- anyways I at least learned something :) Thanks it did work just not supported in game xD
Which game-engine are you using? is it an in-house engine with a custom integration, or one of the UE4 / Unity plugins ? multiple renderers with different positions should be supported regardless of the game-engine. However it's up to the integrator to send the view matrices to the popcorn runtime each frame, so maybe it's missing this? If you're using one of the two plugins, it should be supported.
the game in question is Trove
I'm not sure they implemented that in their integration.
Not sure either which version of popcorn they're using, it might be an old one, before we introduced the view.axis*() functions in v1.10.
Before those functions, the editor and some integrations were detecting float3 attributes named "ViewPosition", "ViewDirection", "ViewSide", etc...

so maybe you can try adding a float3 attribute named "ViewSide", and update your script to use that instead of "view.axisSide()".
If it still doesn't work, well, unless they implement it in their integration, I don't see any other way :(
Maybe you can contact them to explain the issue ?
Right when the game was made I think they were using version then at a later date they updated it to
So I made something else but I have a 2nd solution that I'll give it a try later but might not look good. I'll try that idea as well with the ViewSide.
So I did this for now: https://imgur.com/Chmuk5o
My 2nd solution which is more like a bandaid fix that I'll try at some point: http://prntscr.com/kavd6v
really nice ideas ! :)

You can create a custom texture atlas with overlapping rectangles.
so you could have one number per line, at the texture center, and setup 4 overlapping rects per digit at different 'u' values on that same line, then compute the textureID based on the digit ID.
like, all the left-centered rects appear first in the rectangle list of the atlas, then all the half-left, then all the half-right, the all the right ones.
Really interesting idea !

By the way, looks like you're making some cool things, if you're on facebook there's a PopcornFX user group, feel free to join and share what you're working on if you want! -> https://www.facebook.com/groups/PopcornFXCommunity
0 like 0 dislike


If you are planing on integrating the effect in a game engine, you could just add a localspace evolver to your effect and in the game engine, set the spawner as a child entity of the camera.

Otherwise, you have access to a set of functions to retrieve the camera information in the PopcornFX script:


so you could place the particles in your effect using the view.axis functions.


answered by Paul (7.9k points)