Hi all,
I’m doing a 3D top down game but when the player moves under a tree, I would like some parts of the tree hit by a ray or something, to turn transparent or fade a bit. When the ray no longer touches the object, it should turn solid again. Whats the best way of doing this? I would like it to affect multiple objects if the ray passes through multiple objects, and only ones with the tag of “canFade”.
Is this possible in unity, if so please post some advice (code even better if you could).
Thank you for any help you can give.
I would add a capsule collider to the tree top, when the character enters it, it fades, when he exits it reappears. I would not have a collider on the tree top, just the trunk or something like that.
Thats an interesting idea indeed. Hows the RGBA of a mesh controlled in script so that I might do this. Does need to be compatible with 3g iphones though.
I believe this page should be VERY enlightening for your specific need… as the example does almost exactly what you are asking for.
Assuming that you have one material in your tree top (or roof top or whatever), you can adjust the A value in RGBA by using the material color.
The example in that link also has the other part… Lerp. So do a Lerp over .25 seconds and fade it in and out. In this case it would be a great area to use a StartCoroutine and let that control the colors rather than do it during the update.