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
@@ -12,4 +12,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 541209b3a8828a3429d3a6c93b0350f3, type: 3}
m_Name: BreakableWall
m_EditorClassIdentifier:
ElementType: 0
ElementType: 4
+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;
}
}
}
}