Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Magical Box particles along spline
#1
Hello,

I've experimented a bit with the Curvy Spline, and I've set up particles to move along the length of the spline over the Curvy Spline/Position by Curvy Spline parameter. Is there a way to reverse the flow of particles in the opposite direction on a keypress? I'd want them reversing their flow along the spline, just in reverse.

Also, there seems to be a bug (maybe it isn't) with the particle emitter. If I do something like particlesystem.enabled = true, then switch it to false at some point in order to make the particles disappear, setting it to true again doesn't do anything. Particles don't start working again.

Thank you in advance for the reply.
Reply
#2
(08-15-2013, 08:50 AM)lukasspro777 Wrote: Hello,

I've experimented a bit with the Curvy Spline, and I've set up particles to move along the length of the spline over the Curvy Spline/Position by Curvy Spline parameter. Is there a way to reverse the flow of particles in the opposite direction on a keypress? I'd want them reversing their flow along the spline, just in reverse.

Also, there seems to be a bug (maybe it isn't) with the particle emitter. If I do something like particlesystem.enabled = true, then switch it to false at some point in order to make the particles disappear, setting it to true again doesn't do anything. Particles don't start working again.

Thank you in advance for the reply.
Sorry for the delay, I'll check this tonight!
Reply
#3
(08-16-2013, 06:10 AM)Jake Wrote:
(08-15-2013, 08:50 AM)lukasspro777 Wrote: Hello,

I've experimented a bit with the Curvy Spline, and I've set up particles to move along the length of the spline over the Curvy Spline/Position by Curvy Spline parameter. Is there a way to reverse the flow of particles in the opposite direction on a keypress? I'd want them reversing their flow along the spline, just in reverse.

Also, there seems to be a bug (maybe it isn't) with the particle emitter. If I do something like particlesystem.enabled = true, then switch it to false at some point in order to make the particles disappear, setting it to true again doesn't do anything. Particles don't start working again.

Thank you in advance for the reply.
Sorry for the delay, I'll check this tonight!

Alright. One more question. By using the Curvy Spline/Position by Curvy Spline, I'm running into problems now when it comes to game performance. I have about..12 particle systems that move along splines, and the performance drops severely when I turn on the particles.
Though, 2 or 3 splines have over 100 CP's, could that be the problem? Profile points out that Curvy splines are the ones who take most resources
Reply
#4
(08-16-2013, 09:01 AM)lukasspro777 Wrote:
(08-16-2013, 06:10 AM)Jake Wrote:
(08-15-2013, 08:50 AM)lukasspro777 Wrote: Hello,

I've experimented a bit with the Curvy Spline, and I've set up particles to move along the length of the spline over the Curvy Spline/Position by Curvy Spline parameter. Is there a way to reverse the flow of particles in the opposite direction on a keypress? I'd want them reversing their flow along the spline, just in reverse.

Also, there seems to be a bug (maybe it isn't) with the particle emitter. If I do something like particlesystem.enabled = true, then switch it to false at some point in order to make the particles disappear, setting it to true again doesn't do anything. Particles don't start working again.

Thank you in advance for the reply.
Sorry for the delay, I'll check this tonight!

Alright. One more question. By using the Curvy Spline/Position by Curvy Spline, I'm running into problems now when it comes to game performance. I have about..12 particle systems that move along splines, and the performance drops severely when I turn on the particles.
Though, 2 or 3 splines have over 100 CP's, could that be the problem? Profile points out that Curvy splines are the ones who take most resources

And yeah, could you assist me on the first question I asked?Smile How to make particles move from last CP to first CP, instead of from first to last?
Reply
#5
Ok, finally I have some time for this.

First, I hope with "12 particle systems" you mean 12 Magical Box emitters, not MBParticleSystems. If not, you should change that - a Magical Box emitter is more or less an equivalent to a default ParticleSystem. By having all your effects in a single MBParticleSystem you'll get much performance benefits (mainly by sharing Particle objects, meshes and textures).

About the PositionByCurvySpline: It's more a general all-purpose parameter. That means, some aspects aren't optimized to the max. E.g., if you switch Interpolation from "TFByAge" to a distance based type, performance will suffer (the longer the spline, the slower this will get). Several ways to get around this:

- Use TFByAge if applicable, it's way faster than the other options. If you want particles travel at different speeds, this isn't an option though.
- If you use a distance based interpolation: Lowering a spline's granularity will speed things up.
- Create a custom parameter that does exactly what you want (and not more) in the most performant way.

Switching direction isn't supported yet by the parameter, but I might add it in future versions, sounds quite useful.

So I guess writing a custom parameter is the most useful solution for you. I don't know if you're a coder and how experienced you are, so I can help you by writing a basic custom parameter that does what you want. Also, I'd like to use that opportunity to create a custom parameter tutorial out of this.

In order to do so, I need more information:

1.) Should particles follow the spline exactly (fastest) or should they form a belt/tube around it?
2.) Does particle orientation needs to follow the spline? If you plan to use smoke or dots or similiar, orientation can be ignored by the parameter to speed things up
3.) How should the particle's speed be determined? TFByAge is the fastest, DistanceByAge or DistanceByVelocity is slower. Any other way to calculate speed is working, too. The parameter just somehow needs to know at which position (TF or distance) a particle should be placed at a given time during it's life.
4.) Any other options besides flipping directions?

Jake

PS: Don't be afraid about custom parameters. They're easy to write. They only get complicated if they need to handle as much options at once like the PositionByCurvySpline parameter. But in general custom parameters are a great way to optimize performance and to achieve the very special effect you (and only you) wants!
Reply
#6
(08-17-2013, 09:20 AM)Jake Wrote: Ok, finally I have some time for this.

First, I hope with "12 particle systems" you mean 12 Magical Box emitters, not MBParticleSystems. If not, you should change that - a Magical Box emitter is more or less an equivalent to a default ParticleSystem. By having all your effects in a single MBParticleSystem you'll get much performance benefits (mainly by sharing Particle objects, meshes and textures).

About the PositionByCurvySpline: It's more a general all-purpose parameter. That means, some aspects aren't optimized to the max. E.g., if you switch Interpolation from "TFByAge" to a distance based type, performance will suffer (the longer the spline, the slower this will get). Several ways to get around this:

- Use TFByAge if applicable, it's way faster than the other options. If you want particles travel at different speeds, this isn't an option though.
- If you use a distance based interpolation: Lowering a spline's granularity will speed things up.
- Create a custom parameter that does exactly what you want (and not more) in the most performant way.

Switching direction isn't supported yet by the parameter, but I might add it in future versions, sounds quite useful.

So I guess writing a custom parameter is the most useful solution for you. I don't know if you're a coder and how experienced you are, so I can help you by writing a basic custom parameter that does what you want. Also, I'd like to use that opportunity to create a custom parameter tutorial out of this.

In order to do so, I need more information:

1.) Should particles follow the spline exactly (fastest) or should they form a belt/tube around it?
2.) Does particle orientation needs to follow the spline? If you plan to use smoke or dots or similiar, orientation can be ignored by the parameter to speed things up
3.) How should the particle's speed be determined? TFByAge is the fastest, DistanceByAge or DistanceByVelocity is slower. Any other way to calculate speed is working, too. The parameter just somehow needs to know at which position (TF or distance) a particle should be placed at a given time during it's life.
4.) Any other options besides flipping directions?

Jake

PS: Don't be afraid about custom parameters. They're easy to write. They only get complicated if they need to handle as much options at once like the PositionByCurvySpline parameter. But in general custom parameters are a great way to optimize performance and to achieve the very special effect you (and only you) wants!

Yeah, I thought that the custom code would be the only way to achieve something like this. As for the interpolation type, I do use TFbyAge since its the fastest.

Basically, the thing I have to make are particles going through series of different pipes, each having different shapes and curvatures, hence why I need to use a curvy spline here in order to move the particles along it. But, after I set up particles for one pipe, I also have to make the particles flow in the opposite direction, which kills the performance since it's necessary to make a second Curvy spline and an another particle system. I'm using the Tube parameter, since I need the particles to "stretch out". I'm using the default interpolation (TfbyAge I think) where I use the Lifetime to control their speed. Other than that, I just use the Color > Fixed random gradient to give them some color. Rotation or anything else isn't needed. So yeah, basically I just need to have it move from the last Control Point, to the first, instead of the regular from-first-to-last. I need to have that switched when I want to animate the flow in the opposite direction.

Thank you very much for the assistance, I'm not a very experienced coder sadly, I've only been working in Unity for 3 months maybe and am still learning. Smile I hope to be able to write custom parameters myself somewhere in the future.
Reply
#7
Ok, one more question: When switching direction, how do you want existing particles to behave?

- Continue moving until end reached (=direction is set once at a particle's birth)
- Switch direction immediately and warp position (i.e. a particle that has 75% of it's age will be instantly warp from TF=0.75 to TF=0.25 if you switch direction from forward to backward)
- Switch direction immediately, but keep particle's position and speed (i.e. when switching direction, a particle starts moving in the new direction with constant speed, but will die in between because lifetime exceeds)
- Switch direction immediately and keep position, but increase speed to reach the end before it dies.

Thanks
Jake
Reply
#8
(08-19-2013, 12:16 PM)Jake Wrote: Ok, one more question: When switching direction, how do you want existing particles to behave?

- Continue moving until end reached (=direction is set once at a particle's birth)
- Switch direction immediately and warp position (i.e. a particle that has 75% of it's age will be instantly warp from TF=0.75 to TF=0.25 if you switch direction from forward to backward)
- Switch direction immediately, but keep particle's position and speed (i.e. when switching direction, a particle starts moving in the new direction with constant speed, but will die in between because lifetime exceeds)
- Switch direction immediately and keep position, but increase speed to reach the end before it dies.

Thanks
Jake

Hmmm I'm not quite sure which I'd pick. I'd need the old particles to kinda die off quickly, since if the player switches direction, he's supposed to see the reversed flow of the particles, from the beginning of the pipe, and all the way to the end. Any way to reset the emitter(make all current particles disappear or just die quickly) when direction is switched?
Reply
#9
Of course, I didn't list this option because of it's simplicity Wink

So on switching direction particles will die instantly, behaving like a restart of the emitter with a new direction.
Reply
#10
Hi,

I've exported you my test scene. I used the dev version of Curvy, so propably CurvySpline and CurvySplineSegment scripts are missing when you import that. In this case just drag the CurvySpline script to TubeA/B/C objects and CurvySplineSegment to all CP objects. Alternatively, just delete all tubes, recreate them with your Curvy version and reassign them in the Simple Tube parameter.

Here's the tutorial.

You see, custom parameters aren't rocket science.

Jake


Attached Files
.zip   curvysimpletube.zip (Size: 47.37 KB / Downloads: 3)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy Line Renderer for UI Spline? gekido 1 1 Yesterday, 10:12 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 2 Yesterday, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: