- Home /
This question was
closed May 24, 2014 at 11:50 AM by
Graham-Dunnett for the following reason:
Other
How to make a simple battery?
I have a timer script counting down and I need to make an object with a script so that when you press E on it, it will destroy the object and add 30 seconds to the timer.
This is my timer script: var timer : float = 30.0; var sound: AudioClip; var camera1 : Camera; var camera2 : Camera;
var CameraSwitch : CameraSwitch;
function Awake(){
CameraSwitch = GameObject.Find("camHolder").GetComponent("CameraSwitch");
}
function Update()
{
timer -= Time.deltaTime;
if(timer <= 0)
{
timer = 0;
audio.PlayOneShot(sound);
camera1.gameObject.SetActive(true);
camera2.gameObject.SetActive(false);
CameraSwitch.Playsound();
}
}
function OnGUI()
{
GUI.Box(new Rect(155, 100, 75, 23), "Battery: " + timer.ToString("0"));
}
Comment
Follow this Question
Related Questions
Mini Game Timer - Unity 2017 0 Answers
Countdown/timer in Javascript 3 Answers
Countdown 2 Answers
Counting down in seconds opposed to frames 1 Answer
Calling methods 0 Answers