Well the code there is no errors the trigger destroy the object but not adding the time
I realy appreciate any help to finish my script pls.
This Is My Code
using UnityEngine;
using System.Collections;
public class CountDownTimer : MonoBehaviour {
float timeRemaining = 60.0f;
public void addTime()
{
timeRemaining = 60.00f;
}
public void taketime()
{
timeRemaining -= 10.00f;
}
void Update () {
timeRemaining -= Time.deltaTime;
}
void OnGUI(){
if(timeRemaining > 0){
GUI.Label(new Rect(325, 30, 200, 50),
"Time Remaining : " +timeRemaining);
}
else{
Application.LoadLevel ("Game Over");
}
}
void OnTriggerEnter(Collider other)
{
// The switch statement checks what tag the other gameobject is, and reacts accordingly.
switch(other.gameObject.tag)
{
case "TimePickup":
Invoke("addTime", 3f);
break;
case "TimeOut":
Invoke("addTime", 3f);
break;
}
// Finally, this line destroys the gameObject the player collided with.
Destroy (GameObject.FindWithTag("TimePickup"));
}
}