How to change a powerup into another game object after touch in unity android

I am creating a hyper casual game. In this game there is a powerup mechanics like when a powerup spawn in the game and the user who is playing touch the powerup the powerup destroys and at the same position another helping game object spawns.

You’ll need to break this down into several steps.

  1. Detect touch
  2. Destroy the current GameObject
  3. Instantiate a new GameObject in the same position.

There are a lot of different ways to do this in code, depending on how flexible your solution needs to be. Here is one pattern that I like to use:

Gameobject “A” listens for a touch event. On touch, it destroys itself and notifies some kind of manager script about it’s position. That manager class spawns a new item prefab at the destroy position of the the power up.

Another way to do it would be a parent object that contains both the power up and the new item. On touch the power up turns off, and the new item (or one of several random items) turns on.