我正在嘗試創建一個安全攝像頭,在我一直在構建的遊戲中來回移動。出於某種原因,它只是保持旋轉,從不反轉方向。我嘗試了transform.eulerAngles.y,但沒有成功,也沒有找到任何與Google搜索有關的任何內容。在這個問題上的任何援助將不勝感激:)謝謝你在前進對象旋轉腳本失敗(Unity3d,Boo)
import UnityEngine
class RotationScript (MonoBehaviour):
minRotation = 186
maxRotation = 263
def Start():
transform.Rotate(Vector3.left * Time.deltaTime * 10)
def Update():
if self.transform.rotation.y <= minRotation:
transform.Rotate(Vector3.right * Time.deltaTime * 10)
if self.transform.rotation.y >= maxRotation:
transform.Rotate(Vector3.left * Time.deltaTime * 10)
非常好,謝謝! –