- Home /
How to have separate colliders in a single tile map?
I have created a tile map which has a bunch of tiles which are supposed to get destroyed when hit by a ball, I added a tile map collider and the green boxes seem to appear around every tile separately but when I tested my game, the ball would destroy all the tiles even if it just hit one of them. I would like the tiles to be destroyed separately however but am not sure how to fix this issue. Here is my code to destroy the tiles if it helps :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BallControls : MonoBehaviour
{
void OnCollisionEnter2D(Collision2D collisionBall)
{
if (collisionBall.gameObject.CompareTag("TileBlocks"))
{
Destroy(collisionBall.gameObject); ;
}
}
}
Thanks for any help I recieve!
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613055401im_/https://answers.unity.com/themes/thub/images/avi.jpg)