Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by KayH · Nov 23, 2017 at 09:17 AM · particlesystemfadeoutdecalslifetime

How to fade out decal particles using color over lifetime?

I'm using a particle system to display decals. Play on awake and loop are disabled so the system never plays. Emission is disabled. Color over lifetime is a gradient going from white with alpha 255 to white with alpha 0.

alt text

To write the particles, I set their position, 3drotation, startSize and startColor. They appear as they should, no problem so far.

Now at some point I want to fade out the currently displaying decals. For that I get all the particles, loop through them and set their startLifetime to a few seconds. Then I write them back with SetParticles.

Problem is, they don't fade out but instead all the particles are killed immediately. I checked by trying to get the system's particles in the next Update call (which is only ~1 frame later, not anyone near the lifetime I set) but by then the system is already empty.

particlesystem.jpg (66.3 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by KayH · Nov 23, 2017 at 04:29 PM

To sum up the solution I found with the help of ifurkend:

  • Both startLifetime and remainingLifetime need to be set (to the same value).

  • The particle system needs to be set to play so it actually animates. I set it to stop again when I replace the old decals with new ones, because those should stay put.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by ifurkend · Nov 23, 2017 at 09:40 AM

Just a thought without testing: First you can set startlifetime in the editor to "infinity" if it's indefinite, also just disable color over lifetime module. In the script where you loop the all got particles, don't change their lifetime, but do a lerp of the alpha of startColor (Color32), sth like:

m_particles[i].startColor = new Color32 (m_particles[i].startColor.r, m_particles[i].startColor.g, m_particles[i].startColor.b, Mathf.Lerp(m_particles[i].startColor.a, 0f, time.deltaTime/fadeoutDuration);

if(m_particles[i].startColor.a == 0f){

m_particles[i].remainingLifetime = 0f;

}

Preferably do it in a Coroutine instead of Update.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image KayH · Nov 23, 2017 at 09:48 AM 0
Share

Thanks for the suggestion and yes, I could always do it myself like that. But preferably I'd like to use the functionality offered by the particlesystem class.

So what I'm looking for is an explanation for how to do this with color over lifetime, or an explanation why it simply can't work with lifetime. I'm puzzled why setting a startingLifetime kills the particles immediately (it also does when I do it when they're first created). I don't think this is supposed to happen.

avatar image ifurkend KayH · Nov 23, 2017 at 03:34 PM 0
Share

Have you tried remainingLifetime?

avatar image KayH ifurkend · Nov 23, 2017 at 04:02 PM 0
Share

Yes, I have. Actually that was my first approach. But setting remainingLifetime had no effect at all, i.e. the particles neither faded nor did they disappear/get killed.

Upon closer inspection, the array of particles, which clearly has the remainingLifetime set to 2 for all particles, gets updated when I pass it to SetParticles. Right on the next execution step all the particles suddenly have their remainingLifetime set to 0. Nothing happens afterwards.

I also tried setting both startLifetime and remainingLifetime at the same time, but that results in all of them getting killed immediately also.

So to summarize, setting remainingLifetime does nothing at all and its value gets reset to 0 immediately. And setting startLifetime results in the particles getting instantly killed.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

74 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to destroy / hide a single particle? 2 Answers

Assign random start lifetime for particle system from script 2 Answers

Is it possible to control a particles lifetime(duration) by distance rather than time using code 1 Answer

Dynamic Particle System Lifetime?? 2 Answers

(STILL STUCK!) Align Particle Collsion Sub-Emitter (or decal?) with Surface Normal 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges