Search Unity

Particle Trails With Custom Simulation Space

Discussion in 'General Graphics' started by ODINKONG, Jan 11, 2021.

  1. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    112
    I noticed shuriken has custom simulation space for particles where you choose a transform and simulates the particles relative to the local space of this transform.

    However the trails in the particle system only have a check box for world space or not world space. I'm trying to have a character swing a sword while sliding forward, but I don't want the trail to be effected by the movement forward, Only the sword swing motion. So I want to be able to simulate the trail relative to the characters local space. Does anyone have any ideas about how I might accomplish this?

    The issues with the trail not moving with the player transform is that is sort of ends up inside his own trail and it looks pretty bad.
     

    Attached Files:

  2. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    You might be able to use Ribbon mode for the trails.

    Doing this makes the trail connect actual particles. Therefore those particles can use the custom simulation space.

    Based on your description, perhaps a Rate over Distance emission mode would also be good, to spawn particles along the path of the sword movement.
     
    ODINKONG likes this.
  3. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    112
    Oh man that was very close to solving my issue. It fixes the custom space issue perfectly, but the look has changed dramatically. Is there anyway to get the ribbon to look similar to the previous image. Here is what it looks like in ribbon mode.
     

    Attached Files:

  4. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    Yeah, it requires a slightly different setup. Bit of guesswork on my part, but i think what you have currently is:

    You are spawning particles along the sword, and moving them with the sword. In trail mode, this causes each particle to create a trail. Giving you, something like, 20 trails in total.

    In ribbon mode, you get 1 trail that connects every particle, which is what you're showing here.

    What you can do is, use a sub-emitter to get back to the "20 trails" scenario.
    So, the current master sub-emitter should spawn at the start of the sword swing, and not spawn any more particles after that. Turn off the trails module completely for this, and get rid of rate over distance emission too. You probably want a burst emission at the start of sword swing. you may also want to set the shape module emission mode to "Burst Spread" too, to get your streaks to be distributed evenly along the sword edge.

    Next, add a sub-emitter with its type set to Birth.
    Turn on trails and rate over distance emission for this sub-emitter. get rid of any burst emission, if it has any (i cant recall the defaults)

    Set the trails to Ribbon Mode.

    Finally, in the trails module, there is a "Split sub-emitter ribbons" option. This causes each parent particle to create its own trails, instead of having 1 ribbon connecting everything. Check it, and hopefully you'll now get what you''re after.

    Let us know how this goes :) Good luck!
     
  5. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    112
    Thanks for all the help. Your advice was hugely informative. I've learned a lot. Ultimately I was able to get it looking close to the original trail effect. I had to change the sub emitter from rate over distance to regular over time emision to get it to emit in this setup.

    I think I've got it about as close as possible to the original trail effect in ribbon mode thanks to your help. Unfortunately it's pretty messy. When the particles die the trail sort of jumps around a bit, and currently the trail is destroying in the reverse direction you would expect destroying at the end connected to the sword first and then moving back to where the sword came from. At this point I'm realizing It might be worth making custom sprite animations for the VFX on weapons anyway since we would have a lot of control over them.

    Anyway I attached a GIF of how it turned out if you are curious.

    Thanks again for all the help.
     

    Attached Files:

  6. ODINKONG

    ODINKONG

    Joined:
    Nov 4, 2014
    Posts:
    112
    I definitely prefer the particle trail methods results, but I was hoping there would be a way to have it simulate in a custom transform space, although maybe I'm overacting to the clipping with the character that occurs when I use world space.

    Here is what I'm going with for now. The regular particle trail method. Looks great, but I'm not quite 100% satisfied with the way the forward movement effects it's simulation. Maybe I'm just being picky though honestly.
     

    Attached Files:

  7. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    I see what you mean about the ribbon/sub-emitter attempt - it looks quite messy. There ought to be a way to get it to retract in the correct direction and to use rate over distance, for a smoother trail. Easy for me to say that though, might be harder to actually make it work :) Rate over distance requires positional movement to work, so if you're doing mostly/entirely rotational movement for the sword, that would explain why it's not getting picked up.

    However, your original attempt looks clean and "correct" to me. Personally I don't see anything wrong with the movement on the regular trail method, but I'm no artist and am the first to admit I'm not the best person to give opinions on this aspect ;)

    Hope the process was helpful anyway, even if you're going back to your original attempt!