- Home /
lightup on collision
I want an object to "light up" a certain color when the player collides/bumps into it. The object will fade back to the original color after a certain period of time.
What would be an ideal way to achieve this?
Thank You
Answer by Eric5h5 · Jan 28, 2010 at 04:57 AM
I'd use the Fade script on the wiki, and something like this:
var delay = 2.0; var lightUpColor = Color.yellow; private var originalColor : Color;
function Start () { originalColor = renderer.material.color; }
function OnCollisionEnter () { renderer.material.color = lightUpColor; yield WaitForSeconds(delay); yield Fade.use.Colors(renderer.material, lightUpColor, originalColor, 1.0); }
You might need additional code depending on what you're doing exactly.
Answer by Ashkan_gc · Jan 28, 2010 at 05:30 AM
you can use material.color property and Color.Lerp method to smoothly change the color of your object.
Your answer
Follow this Question
Related Questions
How To Reset Timer on a Collision (C#) 0 Answers
Starting/Stopping a Timer On/Off Collision 1 Answer
Add seconds to timer countdown. 3 Answers
addcount can't add when collide 0 Answers
How can I add time to a timer on an object collision? 1 Answer