Hi everyone, I’ve done a lot of revising to my scripts here:
static var initiated = false;
function OnTriggerEnter (col : Collider) {
if(col.name == "Player")
GameObject.Find("DoubleRockets").GetComponent("gunscript");
gunscript.initialSpeed += 50;
initiated = true;
if(initiated == true)
GameObject.Find("SpeedPowerup1").GetComponent("SpeedPowerup1");
SpeedPowerup1.timerStarted = true;
initiated = false;
Destroy(gameObject);
}
var barDisplay : float = 3;
static var timeLeft : float = 15; //amount of time on timer
static var gunSpeedReduced = false;
static var finishTimer = false; //i made this global so you can access from other scripts
static var timerStarted = false;
function Update() {
if(timerStarted == true) {
timeLeft -= Time.deltaTime;
}
if(timeLeft <= 0.0f) {
timerStarted = false;
}
if(timerStarted == false && timeLeft <= 0.0f) {
Activate();
}
}
function Activate() {
if(timeLeft > 0.0f && gunSpeedReduced == true)
gunSpeedReduced = false;
else if(timeLeft <= 0.0f && gunSpeedReduced == false)
{
GameObject.Find("DoubleRockets").GetComponent("gunscript");
gunscript.initialSpeed -= 50;
gunSpeedReduced = true;
}
}
The problem I am having is that when I collide with a gameobject with the first script attached and the timer runs out, it isn’t resetting if I collide with another gameobject with that same script attached.
Also, I want to have it so that if I collide with two or more game objects with that same script attached, I want the amount of timeLeft to be added to any remaining time already being counted down.
I hope this makes sense and any input or help is greatly appreciated.