Answer the question
In order to leave comments, you need to log in
How to make an object fade in Unity2D through the OnTriggerEnter2D function?
Hello!
I want to implement the following function: when a player enters an opaque texture (that is, into a Trigger), then it becomes transparent, and when it leaves the Trigger's field of action, it becomes opaque again.
Please help, thanks in advance!
Answer the question
In order to leave comments, you need to log in
Change the color property of the SpriteRenderer component. The Color type has 4 channels - red, green, blue and alpha (R,G,B,A). A is responsible for transparency. Accordingly , there will be a translucent sprite. When entering the trigger, we decrease the alpha channel, when we exit, we increase it. new Color(1f, 1f, 1f, 0.5f)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question