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 Messerschmitt · Nov 26, 2013 at 10:15 PM · prefabtouchparticlescolorshuriken

Change prefab color when shuriken particle touches it

I would like to be helped please to change prefabs color if my shuriken particle touches it.

What I would like to do is that each particle that touches my prefab, it will make that prefab color darker and darker (so it will start as white, but change it's color to black after x amount of particles touched it).

Could anyone help me with a script for me that could do that?

Thank you.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by violence · Nov 27, 2013 at 04:32 PM

Breaking your requirement up into parts, it seems this is what you need to do:

  1. Detect collision with your prefab

  2. Detect the object it is colliding with

  3. Change color of that object

This is javascript, I dont know C# but I assume the conversion isn't difficult if required.

I think you can combine 1,2, and 3 into the OnTriggerEnter function: Unity Docs: OnTriggerEnter()

 /* This variable is the amount to which each RGB value is incremented down to 
 black each time it is collided with. RGB value of black is (0,0,0) so eventually 
 it will become black. The higher this number is the lower the number of collisions 
 to get to black.*/
     
 var change : float = 15.0
     
 // this function is called when a collision with this object is detected. 'other' is the object that is colliding with it.    
     
 function OnTriggerEnter (other : Collider) {
     
 other.gameObject.renderer.material.Color32.r = other.gameObject.renderer.material.Color32.r - change;
     
 other.gameObject.renderer.material.Color32.g = other.gameObject.renderer.material.Color32.g - change;
     
 other.gameObject.renderer.material.Color32.b = other.gameObject.renderer.material.Color32.b - change;
                 
 }

Disclaimer: I am not near a computer to test this out, Im sure there are some kinks. I can edit this later if you provide the issues that come up. Also, I am a noob, there very well may be a much easier way to do this.

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

17 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

Related Questions

ParticleAnimator doesn't change color of particles in ParticleSystem(Shuriken) 0 Answers

How do I Update the transform of Instantiate prefab? 2 Answers

Changing color of particles 1 Answer

ray destroying prefab not clone? 2 Answers

Scale Shuriken Particle System with Parent Transform 5 Answers


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