所以我編輯了我的問(wèn)題,因?yàn)槲彝浗o你看一個(gè)相機(jī)腳本。也許問(wèn)題就在那里。我只是相信,即使在編輯舊問(wèn)題之后,也絕對(duì)不會(huì)有人閱讀編輯后的文章。所以我創(chuàng)建了一個(gè)新問(wèn)題。所以我有這樣的問(wèn)題。我試著讓電車動(dòng)起來(lái)。為此,我從 Asset Store“Bezier Path Creator”下載了一個(gè)腳本:https ://assetstore.unity.com/packages/tools/utilities/b-zier-path-creator-136082 。它很好用。之前需要?jiǎng)?chuàng)建第三人稱相機(jī)。在寫(xiě)了一個(gè)簡(jiǎn)短的腳本后,我看到車輛在加速后開(kāi)始抽動(dòng)。我坐了幾天試圖解決這個(gè)問(wèn)題,我看到了一件事。如果刪除* Time.deltaTime,則不再有抽搐,但對(duì) FPS 有依賴性(這是可以預(yù)見(jiàn)的)。此外,如果單擊暫停按鈕并逐幀查看,則不會(huì)出現(xiàn)抽搐。我該怎么辦?有一些代碼我有問(wèn)題: switch (acceleration) { case -1: acc = -12F; break; case -2: acc = -15F; break; case -3: acc = -18F; break; case 0: acc = 0.000f; break; case 1: acc = 9f; break; case 2: acc = 12f; break; case 3: acc = 17.1f; break; } if (Input.GetKeyDown ("e")) { acceleration++; } if (Input.GetKeyDown ("q")) { acceleration--; } if (acceleration < -3) { acceleration = -3; } if (acceleration > 3) { acceleration = 3; }if (speed > 40.0f) { speed = 40.0f; saveSpeed = speed; speed = saveSpeed;} else if (speed >= 0.0f && speed <= 0.03f && acceleration == 0) { speed = 0.0f;} else if (speed <= 0.0f && speed >= -0.03f && acceleration == 0) { speed = 0.0f;} else if (speed <= 40.0f) { speed += ((Time.time - startTime)/1000)*(-acc);}// Taking a piece of Asset Store codetransform.rotation = pathCreator.path.GetRotationAtDistance(distanceTravelled);transform.position = pathCreator.path.GetPointAtDistance(distanceTravelled); // I guess the problem is somewhere there所以有 Asset Store 腳本中的GetRotationAtDistance方法GetPointAtDistance:
車輛抽動(dòng).
慕桂英3389331
2022-11-21 21:29:36