Collide triggers

Hi all - thanks for the awesome and continued help with every question I raise.

I have a problem with a script I’ve found and am slowly modifying. The script has no errors when running but the player fails to actively collide - to the point of actually getting it to print text.

I am assuming its to do with the target variable only referring to Collider - which is nothing at this stage? Do I need to modify this to Gameobject.FirstPlayerController ?

here is my code below.

#pragma strict

var target : Collider; //this is the variable that will hold the colliding object
private var triggered : boolean = false; //If we only want to detect the first time it's triggered
function Start () {
}

function OnTriggerEnter(collision : Collider)
{
  if (collision != target) //The colliding object isn't our object
  {
    return; //don't do anything if it's not our target
  }
  triggered = true;
  print("This worked"); //If you want to have this only trigger once
  //Other code to do stuff on trigger goes here. You could:
  // 1. Increase a variable to keep track of score
  // 2. Transform the colliding object (send the player flying, etc)
  // 3. Play a sound (audio.Play() if you have an audio source)
  // 4. And much, much more
}

Thanks.

You should drag the target object to the field Target in the Inspector - this will save a reference to its collider in the variable target. Once this has been done, the triggered variable will become true whenever the target object enters the trigger. If the trigger is static, it can recognize rigidbodies or character controllers that enter it. If the trigger moves, or if you want to detect colliders that don’t have a rigidbody or character controller, you must add a kinematic rigidbody to it. OnTrigger events are sent to both, the trigger and the other object. The code above apparently is intended to be added to a trigger’s script, because it looks for a specific object (the one dragged to target).