How to make platform detonate when player collides?

I tried looking through previous questions to avoid repeates but I haven’t found one yet… If there was then i apologize and would appreciate it if I was redirected there.

But here is my question. I’m trying to make the platform explode/detonate when the player, it’s a First Person Controller,collides with it. In other words, when the player jumps on top of the platform, the platform will detonate.

There will be multiple platforms but i’m trying to get one working as of now.
I have made a separate empty object called PlatformExplode and a script “explode” associated with the empty object with this in it

var player : GameObject;

var enemy : GameObject;

function Update () {

if(player.collider == enemy.collider)


Instantiate (explosion, transform.position, Quaternion.identity);



Am I missing something? Nothing is happening.

Apologies for the C# but this is a script from a game im working on at the moment. It works without any issues.

if(other.gameObject.tag == “enemy”); //make sure you tag your enemies as “enemy” in unity.




void SpawnExplosion(){

Instantiate(explosionPrefab, transform.position, Quaternion.identity);



Ensure both player and enemy have colliders attached and attach this script to your player.

On a side note; try adding some de-bugging to your scripts to find out where the problem lies, this will let you know if it’s the trigger or the instantiate that isn’t working.

In javascript I would use something like.

function OnTriggerEnter(other:Collider)
   if (other.tag == "Player)
    // Code for detonation


Before you try it, click on your character in the inspector and on the very top menu, change the tag to “Player” so this works.
I don’t know how to code the detonation, so if you know how just put it in there.

otherwise you can not check is Trigger, to pass through, and use OnCollisionEnter

here some reference