所以我得到了这个代码来实例化我的游戏对象加农炮,女巫有一个小孩“球”附加到它。当我使用我的左/右箭头键时,我试图旋转“大炮”周围的“球”。旋转一个带有子对象的游戏对象(Unity 2D)
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public GameObject Cannon = null;
public float speed = 1.0f;
void Start() {
Cannon = Instantiate (Resources.Load ("Prefabs/Cannon")) as GameObject;
}
// Update is called once per frame
void Update() {
if (Input.GetKey(KeyCode.LeftArrow)){
Cannon.transform.Rotate(Vector3.left * speed * Time.deltaTime);
}
if (Input.GetKey(KeyCode.RightArrow)){
Cannon.transform.Rotate(Vector3.right * speed * Time.deltaTime);
}
}
}
但是你遇到的问题是什么? –