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
0
Question by OoglyWoogly · Apr 24, 2011 at 03:32 PM · colorparticle

How to change the colour of particles when colliding with a specific object?

Hi all, I have been trying to get this to work all afternoon and it's driving me crazy. can someone tell me how to alter the colour of particles? I have looked at all the script reference stuff which was not very helpful. Heres what I have got so far:

var laserColourGreen: Color = Color(45.0, 255.0, 0.0, 255.0); var laserColourRed: Color = Color(255.0, 0.0, 0.0, 255.0);

function OnParticleCollision (particle : GameObject) { var laserParticles = particleEmitter.particles; if (particle.gameObject.tag == "Laser") { for (var i = 0; i < laserParticles.Length; i++) { laserParticles[i].color = laserColourRed; } }
else { laserParticles[i].color = laserColourGreen; } particleEmitter.particles = laserParticles; }

This script is attached to the particleEmitter. Any ideas?

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 DaveA · Apr 24, 2011 at 08:05 PM

This looks like it should work. http://unity3d.com/support/documentation/ScriptReference/ParticleEmitter-particles.html Are you sure that this function is getting called? Can you add some Debug.Log and/or run in the debugger?

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 OoglyWoogly · Apr 25, 2011 at 10:58 AM 0
Share

Hmm. I added a print("text") when the laser is supposed to collide but it did not print, so there is obviously some problem there. I also discovered gameobject.tag should have been asteroids, not laser. But changing this did nothing. Very strange

avatar image OoglyWoogly · Apr 25, 2011 at 11:01 AM 0
Share

AHA! I have got the collision working properly now by ticking send collision message in the world particle collider component of the laser, but now it slows down to the extreme whenever it collides. Why would this be happening?

avatar image OoglyWoogly · Apr 25, 2011 at 11:04 AM 0
Share

AHA again! It was because for some inexplicable reason i had the laser emitter pumping out 8000 particles a second. Sorted. Thanks guys

avatar image
0

Answer by tomekkie · Apr 24, 2011 at 06:17 PM

You should probably try to access the renderer>material>shader>color or tint color property.

Basically it depends on particles material; if its none or simple one it should work with color property.

Anyway look at the forum thread:

http://forum.unity3d.com/threads/67725-Adjusting-the-Tint-of-a-Particle-Additive-shader

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

No one has followed this question yet.

Related Questions

Change Particle StartColor 'Random Between Two Colors' 1 Answer

Material doesn't have a color property '_Color' 4 Answers

Changing two different objects renderer colour 1 Answer

Accessing material of particle renderer?? 1 Answer

Accessing and changing particle color in script 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