Third person controller not being destroyed although script works

Hello,

In my game, when a third person controller walks into a box collider - I want to destroy that controller and instantiate a new one.

This is the script I wrote to destroy the first controller:

var thirdPerson : GameObject;


function OnTriggerEnter(other: Collider){

  if (other.tag == "Player")
  { 
    Destroy(thirdPerson);
    }
    
    }

And this is the script to instantiate the new one:

var prefab : Transform;

private var hasPlayed = false;


function OnTriggerEnter () {

var pos : Vector3; 

if (!hasPlayed){

Instantiate (prefab);

hasPlayed = true;

}

}

I tested the scripts on two character controllers that I downloaded from the asset store already animated, and they both worked.

However - I’ve just learnt to animate characters myself (I’m very new to unity) and want to use these instead - but although the new controller is intantiated, the first one isn’t destroyed.

I’ve been through everything I can think of - but I just can’t work out why the characters I’ve animated myself aren’t destroyed when the script itself works.

If anyone has any idea why - please help!

Thanks, Laurien

well if the script is on the character cotroller, it destroys the script and therefore can’t execute it anymore. Try putting the script on an empty gameobject, and on the collider just a trigger with a “sendmessage”.