Best method to spawn polyomino tiles?

If I have 6 basic polyomino shapes with colliders to match. I believe there are two ways to create these at run time.

  1. Use a factory for each shape type and spawn the entire game object with the collision set correctly. So 6 factories.

  2. Use a single factory then change the sprite and enable/disable the collision objects as needed to cover the shape. Since they are polyominos it shouldn’t be too hard to have a shape for each square. Then just enable and disable them accordingly based on the shape selected. As in this example. Each square is easily identified and I can toggle the collisionobject for that square on or off.

Which method is better for performance? And what happens if I need to expand the game and add more shapes? How many factories are too many factories?

Thank you.

I think I’d go for option 1. Having 6 different tiles is not that much and even if you double it it is still relatively easy to manage. Factories are not performance heavy so there’s nothing to worry about.

1 Like