Destroyable tile blocks with TilesExtra
still issues with collider
This commit is contained in:
@@ -12,4 +12,4 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 541209b3a8828a3429d3a6c93b0350f3, type: 3}
|
||||
m_Name: BreakableWall
|
||||
m_EditorClassIdentifier:
|
||||
ElementType: 0
|
||||
ElementType: 4
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user