【发布时间】:2016-04-27 01:10:29
【问题描述】:
尝试使用建议的选项时出现错误 vector3 right is not in its definition 线变换.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。