TNT Explosion + TNT Respawner

In this tutorial we will show you how to make a portable explosive TNT that explodes when hit and respawns after use.

First lets build the TNT.

  • Open up the Library by pressing 'L' on the keyboard. Drag in the TNT asset. You may need to click the Marketplace button and add it to your library if you don't have it.

  • Give the TNT a unique 'Name' that tells you what it does. In this example we used 'TNT - Box Destroyer'

  • Set 'Physics' to 'Collisions + Gravity' so the TNT can be kicked around and falls to the floor.

  • No Behaviours required for this asset.

  • Add the 'Health' Component.

  • Set the asset to low health so it can be destroyed quickly.

  • Set 'Death Delay' to '2' - This is how long it takes to explode after the TNT gets hit.

  • Set 'Instant death message' to 'xxxx' - or anything other then the default message.

  • Set 'Life Bar Display' to 'Always' - If you want it to be obvious to attack it.

  • Add the 'Drop' Component.

  • Set 'Drop condition' to 'Death' - It will drop something when it dies.

  • Set 'Drop Amount' to '1'

  • Set 'Type of drop' to 'Preset' Under the 'Preset' field we select the void preset we will be creating next. We will come back to this later on.

  • Add the 'Indicator' Component

  • Set 'Display Name' to whatever you want the player to see in game. We used 'TNT'

  • Set 'Visibility Distance' to something short. We used '9' block distance.

  • Add the 'Pickable' Component - now the player can Press E to pick up the TNT.

We created a TNT that dies when it gets hit or receives the message 'xxxx' and drops a preset. It has an indicator to alert the players attention to it and we can pick it up or push it around. Now lets create the void that this TNT destroys.

  • Use a small, little detailed asset for the void. In this example we used 'NumPad Switch'

  • Set the void asset to 'Invisible' and 'No collisions'

  • Set a 'Name' so we can search for it later as it needs to be parented to another asset later. We used 'TNT - Void'

  • Add the 'Void' Behaviour and set the 'Visible' setting to 'False'

  • Set 'Destroy Area' to however big of an explosion you want - The bigger the more lag.

  • Set 'Activation Mode' to 'OnStart'

  • Set 'Blocks Destruction' to 'DontDestroy'

  • Set 'Asset Desctruction' to 'OnlyDestroyFromList' and 'Add' your assets you want the TNT to blow up. In this example we only want the 'Storage Container' to be destroyed

  • Add the 'Health' Component

  • Set 'Death Event' to 'Destroy'

  • Set 'Death Delay' to '-1'

  • Set 'Instant death message' to 'tntkillx'

  • Set 'Life Bar Display' to 'Hidden'

We created a void that when it spawns will start instantly to destroy any Storage Containers in the red Destroy Area. We also gave it a health component because we want to destroy the Void once it explodes so it doesn't sit there in the background lagging your game by constantly voiding nothing. So here comes the next step to counter this lag problem. Since the void is set up to destroy 'Storage Container' lets bring one out, this will be used to kill off the void after it is destroyed by the void. Let's see how this is done.

  • Bring out a 'Storage Container'

  • Set the void asset to 'Invisible' and 'No collisions'

  • Set a 'Name' so we can search for it later as it needs to be parented to another asset later. We used 'TNT - VoidKill'

  • Add the 'Health' Component

  • Set 'Death Event' to 'Destroy'

  • Set 'Death Delay' to '1'

  • Set 'Life Bar Display' to 'Hidden'

  • Set 'Message sent on death' to 'tntkillx'

  • Set 'Send To Tags' to 'Void'

  • Click the 'Hierarchy' button in the bottom left corner.

  • Type 'TNT' in the search to bring up all the assets we named with TNT in it.

  • Find the 'TNT - Void' asset in the list, click the target icon and drag it over the 'TNT - VoidKill' Nameplate to parent the object. See image below.

What we have done is made the 2 items as one. When we move the 'Storage Container' around. the 'NumPad Switch' (Void) will follow. Now lets make the 'Storage Container' called 'TNT - VoidKill' into a preset.

  • Select the 'Storage Container' called 'TNT - VoidKill'

  • Click the 'Preset' button in the left side bar.

  • Click the 'Create New Preset' button and click the 'Next' button

Now that the void has been made into the preset, we need to go back to the 'TNT' and set the 'Drop' component to be the preset we just made called 'TNT - VoidKill'

That's it! Now we got a TNT that can explode and it will destroy Storage Containers and then destroy itself to prevent lag in the game. But what about the respawner? Easy done!

  • Select the TNT we made and named 'TNT - Box Destroyer' and create a preset. Just like we did in the last step.

  • Add a 'NumPad Switch' and give it the 'Asset Spawner' Behaviour

  • make it 'Invisible' and 'No Collisions'

  • Set 'Use Preset' to 'True' and select our TNT preset. 'TNT - Box Destroyer'

  • Set 'Message Required' to 'tntkillx'

  • Give the asset the 'Tag' 'Void'

Now when our TNT explodes it spawns an invisible Void and VoidKill. When the VoidKill dies it sends a message to kill the Void it is also sends that same message to the Asset spawner to spawn a new TNT. Pretty cool huh?

Last updated