x


Fading objects towards camera

Hi,

Just wondering if anyone can recommend a good way to achieve this whilst keeping the screen objects click-able?

edit
Sure, I have a camera translating along the Z-axis inside a tunnel with objects ahead. What I would like is for the objects that approach the camera to fade to transparent when a certain distance away. Now, I have tried an approach using a trigger collider placed in front of the camera that detects the object colliders and fades their renderer. This works well but as both the OnCollisionEnter() and OnTriggerEnter() functions both require collider components, it means that I cannot click through this fading collider box to control the player, etc.

Thanks in advance

more ▼

asked Apr 30 '12 at 03:36 PM

asimov gravatar image

asimov
157 18 36 40

@asimov: this time i didn't downvote your answer but instead i merged it into your question. Answers should answer the question. For clarification edit your question or post comments.

May 01 '12 at 04:25 PM Bunny83
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

You could add something like this to the objects:

if(Vector3.Distance(transform.position, Camera.main.transform.position) > fadeDistance)
{
//fade out
}
more ▼

answered May 01 '12 at 04:27 PM

Seth Bergman gravatar image

Seth Bergman
7k 10 16 28

Thanks for the suggestion, Seth - will give a try and let you know how it goes! :0

May 03 '12 at 05:06 PM asimov
(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:

x11
x2

asked: Apr 30 '12 at 03:36 PM

Seen: 498 times

Last Updated: May 03 '12 at 08:15 PM