【发布时间】:2020-08-20 21:27:03
【问题描述】:
我的成就会随着幸存的时间而增加。 我用 Time.time 计算存活时间。当我死时,我会使用 Time.time 值增加成就以增加存活秒数,但它增加的次数远远超过应有的数值。我的代码:
using UnityEngine;
using UnityEngine.UI;
using GooglePlayGames;
public class Timer : MonoBehaviour
{
private float StartTime;
public static float TimerControl;
void Start()
{
StartTime = Time.time;
}
void Update()
{
//The player is alive
if (PlayerController.dead == false)
{
TimerControl = Time.time - StartTime;
}
//The player is dead
if (PlayerController.dead == true)
{
PlayGamesPlatform.Instance.IncrementAchievement(GPGSIds.achievement_survivor, (int)(TimerControl), (bool success) => {
});
}
}
}
在成就中增加的生存时间远远大于应有的时间。
有什么建议吗?谢谢!
【问题讨论】:
-
它增加了多少与应该增加多少?
-
成就是总共生存1小时(3600步,每秒1步)。在我上一次做的测试中,我存活了 23 秒,并且增加了超过 8% 的成就……这没有意义
标签: c# unity3d google-play-games achievements