Destroyable tile blocks with TilesExtra

still issues with collider
This commit is contained in:
2023-06-28 19:58:30 +03:00
parent c79d2a6b49
commit 2dfece0eb0
9 changed files with 1745 additions and 47 deletions
+26 -2
View File
@@ -1,8 +1,32 @@
using UnityEngine;
public class MapElement:MonoBehaviour
public class MapElement : MonoBehaviour
{
[SerializeField]
private MapElementSO _elementSO;
public MapElementSO ElementSO => _elementSO;
}
private float _respawnElementTimer;
private int _respawnTimeout = 4;
private bool _needRespawn = false;
public void Hit()
{
gameObject.GetComponent<BoxCollider2D>().enabled = false;
_needRespawn = true;
}
private void Update()
{
if (_needRespawn)
{
_respawnElementTimer -= Time.deltaTime;
if (_respawnElementTimer <= 0)
{
_respawnElementTimer = _respawnTimeout;
gameObject.GetComponent<BoxCollider2D>().enabled = true;
_needRespawn = false;
}
}
}
}