A 2D Farming RPG
This is just a simple 2D farming RPG game
Loading...
Searching...
No Matches
TriggerObscuringItemFader.cs
Go to the documentation of this file.
1using UnityEngine;
2
8public class TriggerObscuringItemFader : MonoBehaviour
9{
11 private void OnTriggerEnter2D( Collider2D collision )
12 {
13 ObscuringItemFader[] obscuringItemFader = collision.gameObject.GetComponentsInChildren<ObscuringItemFader>();
14
15 if( obscuringItemFader.Length > 0 )
16 {
17 for( int i = 0; i < obscuringItemFader.Length; i++ )
18 {
19 obscuringItemFader[i].FadeOut();
20 }
21 }
22 }
23
25 private void OnTriggerExit2D( Collider2D collision )
26 {
27 ObscuringItemFader[] obscuringItemFader = collision.gameObject.GetComponentsInChildren<ObscuringItemFader>();
28
29 if( obscuringItemFader.Length > 0 )
30 {
31 for( int i = 0; i < obscuringItemFader.Length; i++ )
32 {
33 obscuringItemFader[i].FadeIn();
34 }
35 }
36 }
37}
Used to obscure items when player is behind them. So that player can see the avatar clearly.
void FadeIn()
Start to fade in the object
void FadeOut()
Start to fade out the object
This class trigger fade in and out depending on the distance of the objects that needs to be fade out...
void OnTriggerEnter2D(Collider2D collision)
Get the gameobject we have collided with, and then get all the obscuring item fader components on it ...
void OnTriggerExit2D(Collider2D collision)
Get the gameobject we have collided with, and then get all the obscuring item fader components on it ...