I wrote two scripts, they are nearly identical. The idea is to increment an int value when a collider with a certain tag passes into a collider which is instantiated during the game…
In this case the collider is tagged “TRISERED” (or “TRISERBLUE”) either should increment an int value on PlayerScript.
For some reason, the value will not increment when I make the colliders fall into the trigger. However, with nearly an identical script and identical game objects, it works…
I made sure I have rigid bodies, I made sure mesh colliders were enabled and present, and that the Is Trigger box is checked. I’m pretty sure it is script related. Any help is sincerely appreciated thank you
(The problem is line 21 and 40. They aren’t doing what they say)
#pragma strict
var RED_TRISE_IN_TRIGGER : int;
var BLUE_TRISE_IN_TRIGGER : int;
var RASMUSred : GameObject; //RASMUS to be instantiated for effect and next trigger
var RASMUSblue: GameObject; //RASMUS to be instantiated for effect and next trigger
//var WHATS_AFTER_TRISEred : GameObject;
//var WHATS_AFTER_TRISEblue : GameObject;
//var localScoreBoardScript : GameObject;
//var ScoreBoardlocal : ScoreBoardScript;
//ScoreBoardlocal = GetComponent(ScoreBoardScript);
var target : PlayerScript;
function OnTriggerEnter (other : Collider) {
//************************SCORE POINT FOR RED (PLAYER 1)*****************************************
if (other.CompareTag ("TRISERED")) {
RED_TRISE_IN_TRIGGER++; // Increment Number Of Red TRISE within the Trigger
}
if(RED_TRISE_IN_TRIGGER==3 BLUE_TRISE_IN_TRIGGER<1) {
RASMUSred.transform.position = this.transform.position; //RASMUSred is the instantiated RASMUS after 3 red trise complete to make a rasmus!!!
//Destroy Red Trise's?
Instantiate(RASMUSred);
//Destroy(RASMUSred, 1); ??? Destroy for effect!?
target.fPlayer1ScoreNumber++;
// Increase Player 1 Score in PlayerScript to award a point for completing a RASMUS!
}
//************************SCORE POINT FOR BLUE (PLAYER 2)*****************************************
if (other.CompareTag ("TRISEBLUE")) {
BLUE_TRISE_IN_TRIGGER++; //Increment Number Of Blue TRISE within the Trigger
}
if(BLUE_TRISE_IN_TRIGGER==3 RED_TRISE_IN_TRIGGER<1) {
RASMUSblue.transform.position = this.transform.position; //RASMUS (BLUE) see above!
//Destroy Blue Trise's?
Instantiate(RASMUSblue);
//Instantiate(WHATS_AFTER_RASMUSblue); // ?? neccessary?
//Destroy(WHATS_AFTER_RASMUSblue);
target.fPlayer2ScoreNumber++;
// Increase Player 2 Score in PlayerScript to award a point for completeing a RASMUS!
}
}//function OnTriggerEnter