Summon TNT at arrow after hitting object

I am creating a custom PVP map, where all arrows explode after they hit something. For example, if an arrow hits a block or a non-TNT entity, a TNT is summoned at that location. Here is the command I tried:

Repeating command block, always active:

/execute @e[type=arrow] ~ ~ ~ summon tnt ~ ~ ~

However, when the arrow is shot, TNT spawns wherever the arrow is, creating a disaster. How do I fix this?

Note: If an instant-explosion is possible, I prefer that, but if not, that is okay as well.


Solution 1:

In bedrock edition, you can not detect if an arrow is in the ground, but you can detect if a certain block is under it. You would use a different repeating command block for every possible block it could land on. If your were on a riverbank, it could land on either grass or sand, so it would look like this:

#1: execute @e[type=arrow] ~ ~ ~ detect ~ ~-1 ~ grass 0 summon tnt ~ ~ ~

#2: execute @e[type=arrow] ~ ~ ~ detect ~ ~-1 ~ sand 0 summon tnt ~~~