Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by JimmyJJeeter · Sep 06, 2012 at 08:45 PM · colorparticle

Can I change particle color over time with script?

I want to change the color of particles emitted by an emitter, but I want to change the color that comes out over time. I tried this with legacy particles, setting all 5 colors in the color animator, but it changes all the particle colors. I just want to change the ones being emitted 'right now' and let the ones that already exist keep their color(s) until they die off. Is that possible, maybe with Shuiken? Need to use script, not editor/animator.

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

3 Replies

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

Answer by Screenhog · Sep 06, 2012 at 10:26 PM

Good news, I got it working. I added this script to a Shuriken Particle System. It's not exactly what you want, but it proves that the initial color of the particles can be changed over time:

 var ps: ParticleSystem;
 var psColor: Color;
 
 function Start () {
     ps = GetComponent (ParticleSystem);
 }
 
 function Update () {
     psColor = Color.Lerp(Color.blue, Color.red, Time.time/5);
     ps.startColor = psColor;
 }
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 JimmyJJeeter · Sep 06, 2012 at 11:31 PM 0
Share

Yeah that will change the entire particle set to the new color right? And actually, if I have a gradient set for colorOverLifetime, startColor acts to tint that. So I should leave that white. I'm thinking I need to Get/Set particles and grunt out the colors and hope the system doesn't override them.

avatar image Screenhog · Sep 06, 2012 at 11:37 PM 0
Share

No, each particle as it comes out will be assigned a color, and it will stay as that color, even as the psColor value changes. Don't touch colorOverLifetime (unless I'm misunderstanding the effect you want).

avatar image JimmyJJeeter · Sep 07, 2012 at 12:49 AM 0
Share

Just tried it, yep! Thanks!

avatar image Messerschmitt · Nov 19, 2013 at 05:52 AM 0
Share

Is there a script that would please change the particle colour over Y axis? So as each particle rises up in the Y axis, the colour changes appropriately

avatar image
-1

Answer by Screenhog · Sep 06, 2012 at 09:07 PM

Well, it's easy to do in the editor. By scripting, I don't know.

You access a Shuriken particle system's code through ParticleSystem.startColor. However, that just asks for an initial color, not a gradient of colors (which is what you would assign in the editor). My only thought would be that you constantly change ParticleSystem.startColor over a period of time, perhaps through Color.Lerp. I haven't attempted it myself, but that's the direction I'd go.

Comment
Add comment · Show 3 · 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 JimmyJJeeter · Sep 06, 2012 at 09:33 PM 0
Share

Interesting, I will try but I worry that like with the Legacy particles, I would have to queue the colors, moving the last start color up the line as I change the new start color. Which was not looking too good for me. Actually trying this just now in the editor, I set particle lifetime to 20 seconds, then change the start color. It does change the color of all particles, not just newly-created ones.

avatar image Screenhog · Sep 06, 2012 at 10:10 PM 0
Share

Well, I know that when a gradient is assigned to the start color, it does change over time. But I don't think you can script it to be a gradient.

avatar image JimmyJJeeter · Sep 06, 2012 at 10:14 PM 0
Share

Right, if I could set the gradient for colorOverLifeTime I could at least animate that. I would hate to have to Get/Set particles. $$anonymous$$ight as well write my own system.

avatar image
0

Answer by Charles-Van-Norman · Feb 12, 2017 at 01:06 AM

you can change color over lifetime in Shuriken, it's now covered in the DOCS:

https://docs.unity3d.com/ScriptReference/ParticleSystem-colorOverLifetime.html

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

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

10 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

Related Questions

Accessing and changing particle color in script 1 Answer

Adding a Color Change Script to a Model 1 Answer

Script loads font, how do I change the color? 2 Answers

Modifying a shader color dynamicly through another script 0 Answers

How can I change all of a textures pixels to one color? 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