- Home /
Power up start after 10 seconds of Game play
Hi! I am having a problem regarding a Power up. One of my power ups will be a "Zoom" power up but i cannt manage to make it for the user to activate the power up after 10 second of game play. This is my code
#pragma strict
var zoom : int = 20;
var normal : int = 60;
var smooth : float = 5;
private var zoomedIn = false;
function Update () {
if(Input.GetKeyDown("1")){
zoomedIn = !zoomedIn;
}
if(zoomedIn == true){
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,zoom,Time.deltaTime*smooth);
}
else{
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,normal,Time.deltaTime*smooth);
}
}
Comment
Formatted the code for you this time, try to do it yourself next time. Also be more descriptive with tags.
Answer by Domo23000 · Jun 01, 2014 at 09:26 PM
var zoom : int = 20;
var normal : int = 60;
var smooth : float = 5;
private var zoomedIn = false;
var powerTime : float = 10.0;
function Update () {
if(powerTime > 0)
{
powerTime -= Time.deltaTime;
}
if(powerTime <= 0)
{
if(Input.GetKeyDown("1")){
zoomedIn = !zoomedIn;
}
}
if(zoomedIn == true){
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,zoom,Time.deltaTime*smooth);
}
else{
camera.fieldOfView = Mathf.Lerp(camera.fieldOfView,normal,Time.deltaTime*smooth);
}
}
Is this something that might help? I dont know if this is what you mean. It basically takes 10 seconds, and then lets you use the power.
Your answer
![](https://koobas.hobune.stream/wayback/20220613150535im_/https://answers.unity.com/themes/thub/images/avi.jpg)