I set Time.timeScale = 0 in FixedUpdate(). But, FixedUpdate() can’t stop immediately. Excuse me, why can’t I stop immediately? Thanks for any helpful answers.
This is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class Test_TimeScale_5 : MonoBehaviour
{
private int ph_frame = 0;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void FixedUpdate()
{
ph_frame += 1;
Time.timeScale = 0;
Debug.Log("--FixedUpdate-- [ Time.timeScale=0 ] ----------- frame num: " + ph_frame.ToString());
}
}
Here is log picture:
[131318-qq截图20190117102303.jpg|131318]
There must be something else setting time.timescale to something else than 0, i was testing by changing FixedUpdate frequence in case it has to wait for the next update to change the time.scale value but even changing fixedupdate frequence to 1 or to 0.000001(ended up crashing) the time.scale stop was inmidiate, can you please log Time.timeScale value in the fixed update just for making sure is 0?
Thank you for your help, but the problem is still not solved. This is new code. From the log, I think Time.timeScale value is 0 at runtime. But, FixedUpdate() can’t stop immediately. We are make a physics game, and we hope to stop FixedUpdate() immediately. Sorry, my English is not fluent.
[131339-qq截图20190117202244.jpg|131339]
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class Test_TimeScale_5 : MonoBehaviour
{
private int ph_frame = 0;
void FixedUpdate()
{
ph_frame += 1;
Time.timeScale = 0;
Debug.Log("--FixedUpdate-- [ Time.timeScale=" + Time.timeScale.ToString()+ "], frame num: " + ph_frame.ToString());
}
}