diff --git a/Assets/Scripts/src/Wall/WallTransparency.cs b/Assets/Scripts/src/Wall/WallTransparency.cs index 7522112..baf2509 100644 --- a/Assets/Scripts/src/Wall/WallTransparency.cs +++ b/Assets/Scripts/src/Wall/WallTransparency.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using src.Base; using src.Helpers; @@ -8,6 +9,7 @@ namespace src.Wall { public class WallTransparency : GameplayComponent { + public float secondsToWait = 0.1f; private SpriteRenderer _spriteRenderer; private Color _originalSpriteColor; private bool _isTransparent; @@ -16,21 +18,27 @@ namespace src.Wall { _spriteRenderer = GetComponentInChildren(); _originalSpriteColor = _spriteRenderer.color; + StartCoroutine(nameof(CheckIfSomethingNear)); } - private void Update() + private IEnumerator CheckIfSomethingNear() { - var position = transform.position; - /* RayCast from the center of the tile up one distance and set layerMask to Player only! */ - var hit = Physics2D.Raycast(new Vector2(position.x + .5f, position.y + 0.5f), - Vector2.up, 1f, 1 << 15); - if (hit.collider) + while (true) { - BecomeTransparent(); - } - else - { - BecomeOpaque(); + var position = transform.position; + /* RayCast from the center of the tile up one distance and set layerMask to Player only! */ + var hit = Physics2D.Raycast(new Vector2(position.x + .5f, position.y + 0.5f), + Vector2.up, 1f, 1 << 15); + if (hit.collider) + { + BecomeTransparent(); + } + else + { + BecomeOpaque(); + } + + yield return new WaitForSeconds(secondsToWait); } } diff --git a/ProjectSettings/GraphicsSettings.asset b/ProjectSettings/GraphicsSettings.asset index 44f1158..9a5a0bc 100644 --- a/ProjectSettings/GraphicsSettings.asset +++ b/ProjectSettings/GraphicsSettings.asset @@ -32,6 +32,9 @@ GraphicsSettings: - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 10783, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} m_PreloadedShaders: [] m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}