嘗試使用建議的選項有一個錯誤的Vector3權利並不在其定義 線transform.Rotate(Vector3.Right如何旋轉游戲物體不止一次
預先感謝您
using UnityEngine;
using System.Collections;
public class ForwardBack : MonoBehaviour {
// speed variable
public float speed;
public KeyCode pressLeft;
public KeyCode pressRight;
public float rotationSpeed;
// Use this for initialization
void Start() {
speed = 1f;
}
// Update is called once per frame
void Update() {
transform.Translate(0f, speed*Input.GetAxis("Vertical") * Time.deltaTime,0f);
if (Input.GetKey(KeyCode.RightArrow))
{
transform.Rotate(Vector3.Right * rotationSpeed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.LeftArrow))
{
transform.Rotate(Vector3.Left * rotationSpeed * Time.deltaTime);
}
}
}
(1)它是'transform.eulerAngles'。但在你的情況(2)你只需要'.Rotate',而不是'.eulerAngles'。 – Fattie