我正在 Unity3D 中制作一个跑步游戏,我想检测每次距离(浮点变量(升高 10 以提高速度一点,是否有可能??? 提前致谢:)
好吧,多亏了@mjwills !!!,很快就找到了解决方案 代码如下:
using System.Collections;
using UnityEngine;
public class GameManager : SingleTon<GameManager> {
private float oldDis;
void Start()
{
oldDis = distance;
}
// Update is called once per frame
void Update ()
{
if (distance - oldDis >= 10)
{
Debug.Log("Raised up by 10 and now it's " + distance + " !!!");
oldDis = distance;
}
}
}