public void OnTriggerEnter2D(Collider2D collision) { if (collision.tag != "Player") { hit = Physics2D.CircleCast(transform.position, colliderReference.radius, rigidbodyReference.velocity.normalized, 0.1f, whatIsDestructible); if (hit) { DestructibleTileMap damageable = hit.collider.gameObject.GetComponent <DestructibleTileMap>(); if (!Equals(damageable, null)) { Vector2 positionInTile = (hit.point - (Vector2)transform.position).normalized; damageable.Damage(this, hit.point + (positionInTile.normalized * 0.5f)); } } Destroy(this.gameObject); } }
// Start is called before the first frame update void Start() { destroyable = GameObject.FindGameObjectWithTag("Destructibles").GetComponent <DestructibleTileMap>(); destroyable.DestroyTilesExplosion(GetComponent <CircleCollider2D>().radius, transform.position); Camera.main.GetComponent <CameraShaker>().CamShake(.5f); }