x


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

more ▼

asked Jan 28 '10 at 03:57 AM

unknown gravatar image

unknown
2 1 1 1

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Jan 28 '10 at 04:57 AM

Eric5h5 gravatar image

Eric5h5
80.2k 41 132 519

(comments are locked)
10|3000 characters needed characters left

you can use material.color property and Color.Lerp method to smoothly change the color of your object.

more ▼

answered Jan 28 '10 at 05:30 AM

Ashkan_gc gravatar image

Ashkan_gc
9.1k 33 56 117

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2486
x347

asked: Jan 28 '10 at 03:57 AM

Seen: 1009 times

Last Updated: Jan 28 '10 at 03:57 AM