简体   繁体   中英

Time.deltaTime is 0?

float moveSpeed = 1.5f;
float step = moveSpeed * Time.deltaTime;
StartingFlash.GetComponent<CanvasGroup>().alpha = Mathf.Lerp(StartingFlash.GetComponent<CanvasGroup>().alpha, 0f, step);

So I'm having an issue with lerping, the code above is how I'm currently trying to lerp, but it won't work. When printing Time.deltaTime it's equal to 0 for some reason, making the second variable, step, 0, which is why I believe the lerping isn't working. Is there something I'm doing wrong here? Is this just not the right way to lerp at all? I've tried many ways, and it's still quite confusing to me, so any help is appreciated.

So I figured it out I believe, I tried messing around with the script to see what would happen, so I replaced all Time.deltatime 's with Time.fixedDeltaTime and apparently that works.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM