OnTriggerEnter does nothing ...?

Dear all,

What I do here is instantiating 12 objects in a circle (with a random multiplier). These objects (spheres) have a sphere collider and a box collider(trigger). The idea is that the player (first person) navigates from to object to object, and returns after 4 objects to the very first one. As a measure of accuracy, I calculate the cosine angle.

What I want is that if a player enters the trigger around the red sphere and hits space, the sphere returns to default white. Then, another sphere in the circle turns red.

However, when I run the game and hit space when inside the trigger, nothing happens. Maybe there is confusion because of the two colliders. But I actually have no clue. I have tried millions of things, but I can’t get it to work. I am very new to Unity and JS so please forgive me any newby mistakes or bad programming.

/* 
Creating the little organs in the abdominal cavity
see for reference: http://docs.unity3d.com/Manual/InstantiatingPrefabs.html
*/


import System.Collections.Generic;

private var radians = [2*Mathf.PI, (11/6.0f)*Mathf.PI, (10 /6.0f)*Mathf.PI, (3 /2.0f)*Mathf.PI, (4/3.0f)*Mathf.PI, (7/6.0f)*Mathf.PI, Mathf.PI, (5/6.0f)*Mathf.PI, (4/6.0f)*Mathf.PI, (3/6.0f)*Mathf.PI, (1/3.0f)*Mathf.PI, (1/6.0f)*Mathf.PI];    
private var Organlen : int = radians.length; // length of the object array 
public var radius : float = 9;
public var Organ : GameObject;
//public var OrganTrigger : GameObject;
public var objectsList : List.<GameObject> = new List.<GameObject>(); // empty list with gameobjects
//private var objectsListTrigger : List.<GameObject> = new List.<GameObject>(); // empty list with gameobjects Triggers
private var objects : GameObject;
//private var objectsTrigger : GameObject;
public var count : int = 1;
public var numbers : List.<int> = new List.<int>(12);
private var PlayerInTrigger : boolean = false;  
private var ObjectNumber : int;
private var ObjectSuccession : GameObject;

function Start () {

	// Creating little organs
    for (i = 0; i < Organlen; i++) {
    	var randomizer : float = Random.Range(0.85,1.15); // randomizing the position for a small amount
        var pos = Vector3 ((radius * Mathf.Cos(radians<em>) * randomizer) ,4.0f * randomizer, (radius * Mathf.Sin(radians_) * randomizer));_</em>

objects = Instantiate(Organ, pos, Quaternion.identity) as GameObject;
objects.AddComponent.();
objects.GetComponent.().isTrigger = true;
objects.GetComponent.().size = Vector3(3,3,3);
* //objectsTrigger = Instantiate(OrganTrigger, pos, Quaternion.identity) as GameObject;*
* objectsList.Add(objects);*
* //objectsListTrigger.Add(objectsTrigger);*
* }*

* // Create random sequence*
for (i = 0; i < 12; i++) {
numbers.Add(i);
}

var randomNumbers = new int[8];
for (i = 0; i < randomNumbers.Length; i++) {
var thisNumber = Random.Range(0, numbers.Count);
randomNumbers = numbers[thisNumber];
numbers.RemoveAt(thisNumber);
* }*

* // Make the first object red*
* var ColorObject = numbers[count];*
* var FirstRed : GameObject = objectsList[ColorObject];*
* FirstRed.gameObject.GetComponent.().material.color = Color.red; *
}

function Update()
{
* if (PlayerInTrigger)*
* {*
* if (Input.GetKey(KeyCode.G) && count < 4)*
* {*
* if (count < 4)*
* {*
* // Set the red color to default again when space is hit for active organ*
* ObjectNumber = numbers[count];*
* ObjectSuccession = objectsList[ObjectNumber];*
* ObjectSuccession.gameObject.GetComponent.().material.color = Color.white; *

* // Redefine count, keeping track of how may objects have passed*
* // Make the next one red*
* count = count + 1; *
* var ColorObject : int = numbers[count];*
* var MakeRed : GameObject = objectsList[ColorObject];*
* MakeRed.gameObject.GetComponent.().material.color = Color.red; *
* }*

* if (count == 4)*
* {*
* // Set the red color to default again when space is hit for active organ*
* ObjectNumber = numbers[count];*
* ObjectSuccession = objectsList[ObjectNumber];*
* ObjectSuccession.gameObject.GetComponent.().material.color = Color.white; *

* // redefine count, keeping track of how may objects have passed*
* count = count + 1; *
* }*

* if (count == 5)*
* { *
* // Get Target Response vector*
* var TargetResponse : Vector3 = gameObject.tranform.position;*

* // Get the Correct Target vector*
* var TargetObjectCorrect = numbers[1];*
* var thingy : GameObject = objectsList[TargetObjectCorrect];*
* var TargetCorrect : Vector3 = thingy.transfrom.position;*

* // Calculate the score*
* var angle = Vector3.Angle(TargetResponse, TargetCorrect);*
* var score = Mathf.Cos(angle);*
* Debug.Log(score);*
* } *
* }*
* } *
*} *

function OnTriggerEnter (info : Collider) {

* if (info.tag == “Player”)*
* {*
* PlayerInTrigger = true; *
* }*
*} *

I don’t know if this could be the problem, but you asked “When the player presses Space”, but the script is checking if the player presses “G”.