My timer is not slowing down why?
hello, I have build a timer with a cutout it works perfect but if i want to slow it down it wont work here is my script:
#pragma strict
var speed: float;
var rend: Renderer;
var control: controller;
var mkam: GameObject;
var speeder: float;
var revealOffset: float;
var lastlvl: float;
function Start () {
control = mkam.GetComponent("controller");
lastlvl = 1;
}
function Update () {
speeder = 0.0001 * control.curscore;
revealOffset = rend.material.GetFloat("_Cutoff") + speed + speeder;
rend.material.SetFloat ("_Cutoff", revealOffset);
if(lastlvl != control.curlevel) {
speeder = speeder - 0.001;
lastlvl = control.curlevel;
}
}
the script is checking if your level up if that is so that the line "speeder = speeder - 0.001" is runnng this is where its going wrong.
thank you for lokking and helping
Rick Grendel
Can you please add your code again I think there is some problem when you posted your code.
You decrease the value of speeder
on line 27. But that change is wiped out next time you come into Update()
, where the first line sets it again (to something that doesn't depend on its value). It's not clear what the purpose of the separate speed
and speeder
variables is, are they maybe getting confused?
the speed is the standard speed and the speeder is the speed + extra speed but what can i do to do this good
It depends what you want to achieve. If you want to use the decreased value of speeder (from line 27) then just don't keep resetting it (line 18).
Your answer
![](https://koobas.hobune.stream/wayback/20220612051104im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Can anyone make a timer for me? 0 Answers
How do I respawn something after it's been disabled? 0 Answers
How to start a timer after an update 0 Answers
Add time when collecting objects js 2 Answers