I have a slider that I need to use when the time.scale is set to 0. But the value does not seem to update while it the time scale is 0 is there a way around this? Is this normal or did I cause this? Please help.
This doesn’t sound like a 2D-physics issue as it’s been tagged. Sounds like you’re asking about UI only. Mistake?
Sounds like you wrote a bug… my slider moves all day long with timescale zero.
using UnityEngine;
// @kurtdekker - put this on a Slider you have put in your scene
public class MoveSliderTimeScaleZero : MonoBehaviour
{
void Update ()
{
Time.timeScale = 0;
float time = Time.unscaledTime;
float value = Mathf.PingPong( time * 3.0f, 1.0f);
var slider = GetComponent<UnityEngine.UI.Slider>();
slider.value = value;
}
}
Time for you to start debugging!
By debugging you can find out exactly what your program is doing so you can fix it.
Use the above techniques to get the information you need in order to reason about what the problem is.
You can also use Debug.Log(...);
statements to find out if any of your code is even running. Don’t assume it is.
Once you understand what the problem is, you may begin to reason about a solution to the problem.
Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.
If you are still baffled, how to report your problem productively in the Unity3D forums:
This is the bare minimum of information to report:
- what you want
- what you tried
- what you expected to happen
- what actually happened, log output, variable values, and especially any errors you see
- links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)
The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?
If you post code, only post the relevant code and always use the format button above. Do not post photographs of code.
The problem I am having is not that I cannot change the value of the slider but that when I get the value of the slider it is the same as it was when time scale was set to 0.(This also applies to the max value).
Sorry how do I change that. Is it to late?
I found the problem. For some reason I cant properly get the value of the slider unless I make the slider public and drag and drop it into the script. I dont know why but this works I guess.
Not a problem, I removed it for you.