I’ve been working on a game that procedurally generates dungeons, and I wanted to add collision to the wall tiles, but looking through the documentation, there doesn’t seem to be any methods that let you add a collider through script. And I also already tried using AddComponent but Unity wouldn’t let me use it on the objects I would need to put a collider on. Is there even a way to add colliders onto tiles at runtime?
That’s the correct way, assuming the Collider (or Collider2D) that you want to place is valid on that GameObject.
For instance, you cannot add 2D and 3D colliders (or anything related to physics) on the same GameObject.
Thanks, it took a bit but I got it working
can you share the solution please?