i have a problem with time scale or something like this. The game object should rotating, and i write this:
void Update {
transform.Rotate(Vector3.up * speed);
}
But, when i create the build of game, then in "build-edition" speed gets slower. What should i do? I can give video of this.
You are looking for Time.deltaTime
, which outputs the time difference between the last frame and new frame.
Very much needed as a higher FPS means that more Update()
s are called, resulting inconsistencies in movement.
Multiplying any movement by time-scale will help to normalize the movement across different FPS.
void Update() {
// Will rotate significantly slower, increase the 'speed' variable.
// But rotation speed will normalize across different FPS.
transform.Rotate(Vector3.up * speed * Time.deltaTime);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.