【发布时间】:2019-05-01 05:09:16
【问题描述】:
我遇到过这样一种情况,如果 Time.time 在 Update() 中不同通道的两个不同位置调用,则值会有所不同 因此,在其增量中,任何使用 Vector3(0,Time.time,0) 都会导致 结果跳跃。我有一个开始路径的游戏对象 一段代码然后进一步转换到另一组代码 在脚本中。 Time.time 在第一次调用中的间隙执行和 第二个调用不同于第一个循环中的间隙 称呼。这就是为什么我要求更换。它与代码无关。它是关于两个 Time.time 用法之间的 Time.time 差异。我相信存在执行导致的差异。
void Update () {
synchTime = Time.time;
// This proc releases gameobject from center into an outward spiralling trajectory till the height orbit path attained,
// then disables itself releasing the gameobject into the sine wave orbital path.
if (!reachedElevation)
{
transform.Translate(0, Time.deltaTime, 0);
reachedElevation = true;
_AgentY = Mathf.Sin(synchTime);//Keeps value started and in synch with usage below
}else{
// The trouble is making the 'Y' synch between where the spiral left off and this sine. It has to do with Time.time
_AgentY = Mathf.Sin(synchTime);
Debug.Log("Before transform.localPosition.y: " + transform.localPosition.y);
transform.localPosition = new Vector3(transform.localPosition.x, _AgentY, transform.localPosition.z);
Debug.Log("After transform.localPosition.y: " + transform.localPosition.y);
}
}
【问题讨论】: