按下水平箭头键时,我正在尝试旋转对象Cannon。我的C#脚本看起来像这样;但遗憾的是我在Unity中解析错误和“Unexpecting symbol”{'“:(
使用UnityEngine; 使用System.Collections;
public class NewBehaviourScript:MonoBehaviour {
public float HorizontalKeys;
public Transform Cannon;
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetAxis("HorizontalKeys")){
if(Input.GetAxis ("HorizontalKeys" == -1){
Cannon.transform.Rotate(Vector3.right * Time.deltaTime);
Debug.Log("Test");
}if(Input.GetKey ("HorizontalKeys" == 1){
Cannon.transform.Rotate(Vector3.left * Time.deltaTime);
Debug.Log("Test");
}
}
}
}
答案 0 :(得分:0)
使用附件")"
完成if语句if(Input.GetAxis ("HorizontalKeys" == -1)) {
}