Yeah the first debug log outputs just fine. It’s the collision part that isn’t working. I can instantiate the circle collider just fine, and I have even paused the game and SEEN the circle collider, so I know it is working. I just can’t get other blocks to recognize that they colliding with the circle collider and that they need to be blown up! Here is what I am trying now. One method to instantiate the explosion circle collider. This part works fine:
private void Explosion()
{
{
gameObject.AddComponent<CircleCollider2D>();
myExplosion = GetComponent<CircleCollider2D>();
myExplosion.isTrigger = true;
myExplosion.radius = explosionRadius;
Debug.Log("Explosion Successful!");
}
}
And another method to check for a collision with a circle collider:
private void OnTriggerEnter2D(Collider2D collider2D)
{
Debug.Log("PLZ WORK");
}
I have been trying to distinguish this collision detection from the collision detection between the ball and the block by making the explosion collider a “trigger”, but that hasn’t worked so well yet. What I have noticed is that if I turn off the destroy part of the block hit like this:
private void DestroyBlock()
{
AudioSource.PlayClipAtPoint(blockDestroy, Camera.main.transform.position);
TriggerSparklesVFX();
Explosion();
FindObjectOfType<GameSession>().AddToScore();
level.BlockDestroyed();
//Destroy(gameObject);
}
Then I can actually get the PLZ WORK message to show up. So the block may be getting destroyed too fast before it can actually cause an explosion. I don’t know man. This is driving me nuts. Hope some part of this makes sense.